diff --git a/packages/flutter/lib/src/material/input_decorator.dart b/packages/flutter/lib/src/material/input_decorator.dart index c54ba8a05a..d957c7aaf2 100644 --- a/packages/flutter/lib/src/material/input_decorator.dart +++ b/packages/flutter/lib/src/material/input_decorator.dart @@ -1410,7 +1410,7 @@ class _RenderDecoration extends RenderBox with SlottedContainerRenderObjectMixin double start = right - _boxSize(icon).width; double end = left; if (prefixIcon != null) { - start += contentPadding.left; + start += contentPadding.right; start -= centerLayout(prefixIcon!, start - prefixIcon!.size.width); } if (label != null) { diff --git a/packages/flutter/test/material/input_decorator_test.dart b/packages/flutter/test/material/input_decorator_test.dart index 4d543a8d98..7755053967 100644 --- a/packages/flutter/test/material/input_decorator_test.dart +++ b/packages/flutter/test/material/input_decorator_test.dart @@ -6516,5 +6516,35 @@ void main() { final Text hintTextWidget = tester.widget(hintTextFinder); 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)); + }); } }