Fixes multi line textfield hint text gets ellipsized (#148423)
fixes https://github.com/flutter/flutter/issues/148353
This commit is contained in:
parent
5e448f4ce5
commit
6ec1c75ac7
@ -2164,7 +2164,7 @@ class _InputDecoratorState extends State<InputDecorator> with TickerProviderStat
|
||||
hintText,
|
||||
style: hintStyle,
|
||||
textDirection: decoration.hintTextDirection,
|
||||
overflow: hintStyle.overflow ?? TextOverflow.ellipsis,
|
||||
overflow: hintStyle.overflow ?? (decoration.hintMaxLines == null ? null : TextOverflow.ellipsis),
|
||||
textAlign: textAlign,
|
||||
maxLines: decoration.hintMaxLines,
|
||||
),
|
||||
|
@ -1875,6 +1875,48 @@ void main() {
|
||||
expect(find.text('Paste'), findsOneWidget);
|
||||
}, skip: isContextMenuProvidedByPlatform); // [intended] only applies to platforms where we supply the context menu.
|
||||
|
||||
testWidgets('infinite multi-line text hint text is not ellipsized by default', (WidgetTester tester) async {
|
||||
const String kLongString =
|
||||
'Enter your email Enter your email Enter your '
|
||||
'email Enter your email Enter your email Enter '
|
||||
'your email Enter your email';
|
||||
const double defaultLineHeight = 24;
|
||||
await tester.pumpWidget(overlay(
|
||||
child: const TextField(
|
||||
maxLines: null,
|
||||
decoration: InputDecoration(
|
||||
labelText: 'Email',
|
||||
hintText: kLongString,
|
||||
),
|
||||
),
|
||||
));
|
||||
final Text hintText = tester.widget<Text>(find.text(kLongString));
|
||||
expect(hintText.overflow, isNull);
|
||||
final RenderParagraph paragraph = tester.renderObject<RenderParagraph>(find.text(kLongString));
|
||||
expect(paragraph.size.height > defaultLineHeight * 2, isTrue);
|
||||
});
|
||||
|
||||
testWidgets('non-infinite multi-line hint text is ellipsized by default', (WidgetTester tester) async {
|
||||
const String kLongString =
|
||||
'Enter your email Enter your email Enter your '
|
||||
'email Enter your email Enter your email Enter '
|
||||
'your email Enter your email';
|
||||
const double defaultLineHeight = 24;
|
||||
await tester.pumpWidget(overlay(
|
||||
child: const TextField(
|
||||
maxLines: 2,
|
||||
decoration: InputDecoration(
|
||||
labelText: 'Email',
|
||||
hintText: kLongString,
|
||||
),
|
||||
),
|
||||
));
|
||||
final Text hintText = tester.widget<Text>(find.text(kLongString));
|
||||
expect(hintText.overflow, TextOverflow.ellipsis);
|
||||
final RenderParagraph paragraph = tester.renderObject<RenderParagraph>(find.text(kLongString));
|
||||
expect(paragraph.size.height < defaultLineHeight * 2 + precisionErrorTolerance, isTrue);
|
||||
});
|
||||
|
||||
testWidgets('Entering text hides selection handle caret', (WidgetTester tester) async {
|
||||
final TextEditingController controller = _textEditingController();
|
||||
|
||||
|
Loading…
x
Reference in New Issue
Block a user