RTL InputDecoration fix (#129661)
Fixes InputDecoration (TextField) layout when 1. RTL 2. prefixIcon and 3. left/right contentPadding is asymmetric.
This commit is contained in:
parent
c1b764a80f
commit
c7511664e2
@ -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() {
|
|||||||
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));
|
||||||
|
});
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
Loading…
x
Reference in New Issue
Block a user