diff --git a/packages/flutter/lib/src/material/input_decorator.dart b/packages/flutter/lib/src/material/input_decorator.dart index 66debd86eb..c673072358 100644 --- a/packages/flutter/lib/src/material/input_decorator.dart +++ b/packages/flutter/lib/src/material/input_decorator.dart @@ -2164,7 +2164,7 @@ class _InputDecoratorState extends State 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, ), diff --git a/packages/flutter/test/material/text_field_test.dart b/packages/flutter/test/material/text_field_test.dart index 516f4332e5..1f667d152e 100644 --- a/packages/flutter/test/material/text_field_test.dart +++ b/packages/flutter/test/material/text_field_test.dart @@ -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(find.text(kLongString)); + expect(hintText.overflow, isNull); + final RenderParagraph paragraph = tester.renderObject(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(find.text(kLongString)); + expect(hintText.overflow, TextOverflow.ellipsis); + final RenderParagraph paragraph = tester.renderObject(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();