Skip to content

Commit 497a528

Browse files
authored
Fix TextField/CupertinoTextField hint style overflow not work. (#114335)
* 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.
1 parent 496cf62 commit 497a528

File tree

2 files changed

+26
-1
lines changed

2 files changed

+26
-1
lines changed

packages/flutter/lib/src/cupertino/text_field.dart

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1133,7 +1133,7 @@ class _CupertinoTextFieldState extends State<CupertinoTextField> with Restoratio
11331133
child: Text(
11341134
widget.placeholder!,
11351135
maxLines: widget.maxLines,
1136-
overflow: TextOverflow.ellipsis,
1136+
overflow: placeholderStyle.overflow ?? TextOverflow.ellipsis,
11371137
style: placeholderStyle,
11381138
textAlign: widget.textAlign,
11391139
),

packages/flutter/test/cupertino/text_field_test.dart

Lines changed: 25 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -7485,4 +7485,29 @@ void main() {
74857485
expect(controller.text, cutValue);
74867486
}
74877487
});
7488+
7489+
testWidgets('placeholder style overflow works', (WidgetTester tester) async {
7490+
final String placeholder = 'hint text' * 20;
7491+
const TextStyle placeholderStyle = TextStyle(
7492+
fontFamily: 'Ahem',
7493+
fontSize: 14.0,
7494+
overflow: TextOverflow.fade,
7495+
);
7496+
7497+
await tester.pumpWidget(
7498+
CupertinoApp(
7499+
home: Center(
7500+
child: CupertinoTextField(
7501+
placeholder: placeholder,
7502+
placeholderStyle: placeholderStyle,
7503+
),
7504+
),
7505+
),
7506+
);
7507+
await tester.pumpAndSettle();
7508+
final Finder placeholderFinder = find.text(placeholder);
7509+
final Text placeholderWidget = tester.widget(placeholderFinder);
7510+
expect(placeholderWidget.overflow, placeholderStyle.overflow);
7511+
expect(placeholderWidget.style!.overflow, placeholderStyle.overflow);
7512+
});
74887513
}

0 commit comments

Comments
 (0)