Unverified Commit c7511664 authored by Justin McCandless's avatar Justin McCandless Committed by GitHub

RTL InputDecoration fix (#129661)

Fixes InputDecoration (TextField) layout when 1. RTL 2. prefixIcon and 3. left/right contentPadding is asymmetric.
parent c1b764a8
...@@ -1410,7 +1410,7 @@ class _RenderDecoration extends RenderBox with SlottedContainerRenderObjectMixin ...@@ -1410,7 +1410,7 @@ class _RenderDecoration extends RenderBox with SlottedContainerRenderObjectMixin
double start = right - _boxSize(icon).width; double start = right - _boxSize(icon).width;
double end = left; double end = left;
if (prefixIcon != null) { if (prefixIcon != null) {
start += contentPadding.left; start += contentPadding.right;
start -= centerLayout(prefixIcon!, start - prefixIcon!.size.width); start -= centerLayout(prefixIcon!, start - prefixIcon!.size.width);
} }
if (label != null) { if (label != null) {
......
...@@ -6516,5 +6516,35 @@ void main() { ...@@ -6516,5 +6516,35 @@ void main() {
final Text hintTextWidget = tester.widget(hintTextFinder); final Text hintTextWidget = tester.widget(hintTextFinder);
expect(hintTextWidget.style!.overflow, decoration.hintStyle!.overflow); expect(hintTextWidget.style!.overflow, decoration.hintStyle!.overflow);
}); });
testWidgets('prefixIcon in RTL with asymmetric padding', (WidgetTester tester) async {
// Regression test for https://github.com/flutter/flutter/issues/129591
const InputDecoration decoration = InputDecoration(
contentPadding: EdgeInsetsDirectional.only(end: 24),
prefixIcon: Focus(child: Icon(Icons.search)),
);
await tester.pumpWidget(
buildInputDecorator(
useMaterial3: useMaterial3,
// isEmpty: false (default)
// isFocused: false (default)
decoration: decoration,
textDirection: TextDirection.rtl,
),
);
await tester.pumpAndSettle();
expect(find.byType(InputDecorator), findsOneWidget);
expect(find.byType(Icon), findsOneWidget);
final Offset(dx: double decoratorRight) =
tester.getTopRight(find.byType(InputDecorator));
final Offset(dx: double prefixRight) =
tester.getTopRight(find.byType(Icon));
// The prefix is inside the decorator.
expect(decoratorRight, lessThanOrEqualTo(prefixRight));
});
} }
} }
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment