diff --git a/packages/flutter/lib/src/cupertino/text_field.dart b/packages/flutter/lib/src/cupertino/text_field.dart index 09a0e0c65068..81627d8e1a4c 100644 --- a/packages/flutter/lib/src/cupertino/text_field.dart +++ b/packages/flutter/lib/src/cupertino/text_field.dart @@ -5,6 +5,7 @@ import 'package:flutter/gestures.dart'; import 'package:flutter/rendering.dart'; import 'package:flutter/services.dart'; import 'package:flutter/widgets.dart'; +import 'package:flutter/material.dart' show TextAlignVertical; import 'colors.dart'; import 'icons.dart'; @@ -174,6 +175,7 @@ class CupertinoTextField extends StatefulWidget { this.style, this.strutStyle, this.textAlign = TextAlign.start, + this.textAlignVertical = TextAlignVertical.top, // TODO(justinmc): Match previous behavior of if prefix then center this.readOnly = false, this.showCursor, this.autofocus = false, @@ -323,6 +325,9 @@ class CupertinoTextField extends StatefulWidget { /// {@macro flutter.widgets.editableText.textAlign} final TextAlign textAlign; + /// {@macro flutter.material.inputDecorator.textAlignVertical} + final TextAlignVertical textAlignVertical; + /// {@macro flutter.widgets.editableText.readOnly} final bool readOnly; @@ -487,6 +492,8 @@ class CupertinoTextField extends StatefulWidget { properties.add(FlagProperty('selectionEnabled', value: selectionEnabled, defaultValue: true, ifFalse: 'selection disabled')); properties.add(DiagnosticsProperty('scrollController', scrollController, defaultValue: null)); properties.add(DiagnosticsProperty('scrollPhysics', scrollPhysics, defaultValue: null)); + properties.add(EnumProperty('textAlign', textAlign, defaultValue: TextAlign.start)); + properties.add(DiagnosticsProperty('textAlignVertical', textAlignVertical, defaultValue: null)); } } @@ -722,7 +729,10 @@ class _CupertinoTextFieldState extends State with AutomaticK widget.clearButtonMode == OverlayVisibilityMode.never && widget.prefix == null && widget.suffix == null) { - return editableText; + return Align( + alignment: Alignment(-1.0, widget.textAlignVertical.y), + child: editableText, + ); } // Otherwise, listen to the current state of the text entry. @@ -789,7 +799,13 @@ class _CupertinoTextFieldState extends State with AutomaticK ); } - return Row(children: rowChildren); + return Align( + alignment: Alignment(-1.0, widget.textAlignVertical.y), + child: Row( + crossAxisAlignment: CrossAxisAlignment.start, + children: rowChildren, + ), + ); }, ); } diff --git a/packages/flutter/lib/src/material/input_decorator.dart b/packages/flutter/lib/src/material/input_decorator.dart index e1b601d308da..a16297601428 100644 --- a/packages/flutter/lib/src/material/input_decorator.dart +++ b/packages/flutter/lib/src/material/input_decorator.dart @@ -3537,6 +3537,8 @@ class InputDecorationTheme extends Diagnosticable { /// See also: /// /// * [TextField.textAlignVertical], which is passed on to the [InputDecorator]. +/// * [CupertinoTextField.textAlignVertical], which behaves in the same way as +/// the parameter in TextField. /// * [InputDecorator.textAlignVertical], which defines the alignment of /// prefix, input, and suffix, within the [InputDecorator]. class TextAlignVertical {