Skip to content

Commit

Permalink
Use hintText's TextStyle overflow (flutter#114378)
Browse files Browse the repository at this point in the history
hinText's overflow can now be set via hintStyle (in InputDecoration)
  • Loading branch information
justinmc committed Nov 1, 2022
1 parent 0d65b63 commit 8a8b361
Show file tree
Hide file tree
Showing 2 changed files with 27 additions and 1 deletion.
2 changes: 1 addition & 1 deletion packages/flutter/lib/src/material/input_decorator.dart
Original file line number Diff line number Diff line change
Expand Up @@ -2150,7 +2150,7 @@ class _InputDecoratorState extends State<InputDecorator> with TickerProviderStat
hintText,
style: hintStyle,
textDirection: decoration.hintTextDirection,
overflow: TextOverflow.ellipsis,
overflow: hintStyle.overflow ?? TextOverflow.ellipsis,
textAlign: textAlign,
maxLines: decoration.hintMaxLines,
),
Expand Down
26 changes: 26 additions & 0 deletions packages/flutter/test/material/input_decorator_test.dart
Original file line number Diff line number Diff line change
Expand Up @@ -6050,7 +6050,33 @@ void main() {
await tester.pumpWidget(buildFrame(true));
await tester.pumpAndSettle();
expect(tester.getTopLeft(find.text('label')).dy, useMaterial3 ? -4.75 : -5.5);
});

testWidgets('hint style overflow works', (WidgetTester tester) async {
final String hintText = 'hint text' * 20;
const TextStyle hintStyle = TextStyle(
fontFamily: 'Ahem',
fontSize: 14.0,
overflow: TextOverflow.fade,
);
final InputDecoration decoration = InputDecoration(
hintText: hintText,
hintStyle: hintStyle,
);

await tester.pumpWidget(
buildInputDecorator(
useMaterial3: useMaterial3,
// isEmpty: false (default)
// isFocused: false (default)
decoration: decoration,
),
);
await tester.pumpAndSettle();

final Finder hintTextFinder = find.text(hintText);
final Text hintTextWidget = tester.widget(hintTextFinder);
expect(hintTextWidget.style!.overflow, decoration.hintStyle!.overflow);
});
}
}

0 comments on commit 8a8b361

Please sign in to comment.