Skip to content
This repository was archived by the owner on Feb 22, 2023. It is now read-only.

Commit 8a8b361

Browse files
authored
Use hintText's TextStyle overflow (#114378)
hinText's overflow can now be set via hintStyle (in InputDecoration)
1 parent 0d65b63 commit 8a8b361

File tree

2 files changed

+27
-1
lines changed

2 files changed

+27
-1
lines changed

packages/flutter/lib/src/material/input_decorator.dart

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -2150,7 +2150,7 @@ class _InputDecoratorState extends State<InputDecorator> with TickerProviderStat
21502150
hintText,
21512151
style: hintStyle,
21522152
textDirection: decoration.hintTextDirection,
2153-
overflow: TextOverflow.ellipsis,
2153+
overflow: hintStyle.overflow ?? TextOverflow.ellipsis,
21542154
textAlign: textAlign,
21552155
maxLines: decoration.hintMaxLines,
21562156
),

packages/flutter/test/material/input_decorator_test.dart

Lines changed: 26 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -6050,7 +6050,33 @@ void main() {
60506050
await tester.pumpWidget(buildFrame(true));
60516051
await tester.pumpAndSettle();
60526052
expect(tester.getTopLeft(find.text('label')).dy, useMaterial3 ? -4.75 : -5.5);
6053+
});
6054+
6055+
testWidgets('hint style overflow works', (WidgetTester tester) async {
6056+
final String hintText = 'hint text' * 20;
6057+
const TextStyle hintStyle = TextStyle(
6058+
fontFamily: 'Ahem',
6059+
fontSize: 14.0,
6060+
overflow: TextOverflow.fade,
6061+
);
6062+
final InputDecoration decoration = InputDecoration(
6063+
hintText: hintText,
6064+
hintStyle: hintStyle,
6065+
);
6066+
6067+
await tester.pumpWidget(
6068+
buildInputDecorator(
6069+
useMaterial3: useMaterial3,
6070+
// isEmpty: false (default)
6071+
// isFocused: false (default)
6072+
decoration: decoration,
6073+
),
6074+
);
6075+
await tester.pumpAndSettle();
60536076

6077+
final Finder hintTextFinder = find.text(hintText);
6078+
final Text hintTextWidget = tester.widget(hintTextFinder);
6079+
expect(hintTextWidget.style!.overflow, decoration.hintStyle!.overflow);
60546080
});
60556081
}
60566082
}

0 commit comments

Comments
 (0)