Skip to content

Commit

Permalink
Fix TextField/CupertinoTextField hint style overflow not work. (#114335)
Browse files Browse the repository at this point in the history
* fix text field hint style overflow not work, keep default ellipsis.

* fix cupertino text field hint style overflow not work, keep default ellipsis.

* add Cupertino placeholder style test.
  • Loading branch information
ksballetba authored Nov 7, 2022
1 parent 496cf62 commit 497a528
Show file tree
Hide file tree
Showing 2 changed files with 26 additions and 1 deletion.
2 changes: 1 addition & 1 deletion packages/flutter/lib/src/cupertino/text_field.dart
Original file line number Diff line number Diff line change
Expand Up @@ -1133,7 +1133,7 @@ class _CupertinoTextFieldState extends State<CupertinoTextField> with Restoratio
child: Text(
widget.placeholder!,
maxLines: widget.maxLines,
overflow: TextOverflow.ellipsis,
overflow: placeholderStyle.overflow ?? TextOverflow.ellipsis,
style: placeholderStyle,
textAlign: widget.textAlign,
),
Expand Down
25 changes: 25 additions & 0 deletions packages/flutter/test/cupertino/text_field_test.dart
Original file line number Diff line number Diff line change
Expand Up @@ -7485,4 +7485,29 @@ void main() {
expect(controller.text, cutValue);
}
});

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

await tester.pumpWidget(
CupertinoApp(
home: Center(
child: CupertinoTextField(
placeholder: placeholder,
placeholderStyle: placeholderStyle,
),
),
),
);
await tester.pumpAndSettle();
final Finder placeholderFinder = find.text(placeholder);
final Text placeholderWidget = tester.widget(placeholderFinder);
expect(placeholderWidget.overflow, placeholderStyle.overflow);
expect(placeholderWidget.style!.overflow, placeholderStyle.overflow);
});
}

0 comments on commit 497a528

Please sign in to comment.