fixed cupertinoTextField placeholder textAlign (#33739)
This commit is contained in:
@@ -744,13 +744,17 @@ class _CupertinoTextFieldState extends State<CupertinoTextField> with AutomaticK
|
||||
// if needed.
|
||||
if (widget.placeholder != null && text.text.isEmpty) {
|
||||
stackChildren.add(
|
||||
Padding(
|
||||
padding: widget.padding,
|
||||
child: Text(
|
||||
widget.placeholder,
|
||||
maxLines: 1,
|
||||
overflow: TextOverflow.ellipsis,
|
||||
style: placeholderStyle
|
||||
SizedBox(
|
||||
width: double.infinity,
|
||||
child: Padding(
|
||||
padding: widget.padding,
|
||||
child: Text(
|
||||
widget.placeholder,
|
||||
maxLines: widget.maxLines,
|
||||
overflow: TextOverflow.ellipsis,
|
||||
style: placeholderStyle,
|
||||
textAlign: widget.textAlign,
|
||||
),
|
||||
),
|
||||
),
|
||||
);
|
||||
|
||||
@@ -544,6 +544,31 @@ void main() {
|
||||
},
|
||||
);
|
||||
|
||||
testWidgets(
|
||||
'placeholder respects textAlign',
|
||||
(WidgetTester tester) async {
|
||||
await tester.pumpWidget(
|
||||
const CupertinoApp(
|
||||
home: Center(
|
||||
child: CupertinoTextField(
|
||||
placeholder: 'placeholder',
|
||||
textAlign: TextAlign.right,
|
||||
),
|
||||
),
|
||||
),
|
||||
);
|
||||
|
||||
final Text placeholder = tester.widget(find.text('placeholder'));
|
||||
expect(placeholder.textAlign, TextAlign.right);
|
||||
|
||||
await tester.enterText(find.byType(CupertinoTextField), 'input');
|
||||
await tester.pump();
|
||||
|
||||
final EditableText inputText = tester.widget(find.text('input'));
|
||||
expect(placeholder.textAlign, inputText.textAlign);
|
||||
},
|
||||
);
|
||||
|
||||
testWidgets(
|
||||
'placeholders are lightly colored and disappears once typing starts',
|
||||
(WidgetTester tester) async {
|
||||
|
||||
Reference in New Issue
Block a user