Commit 91213e2e authored by Haijun's avatar Haijun Committed by LongCatIsLooong

fixed cupertinoTextField placeholder textAlign (#33739)

parent c50fa3d2
......@@ -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 {
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment