@@ -239,6 +239,7 @@ class CupertinoTextField extends StatefulWidget {
239239 this .prefixMode = OverlayVisibilityMode .always,
240240 this .suffix,
241241 this .suffixMode = OverlayVisibilityMode .always,
242+ this .crossAxisAlignment = CrossAxisAlignment .center,
242243 this .clearButtonMode = OverlayVisibilityMode .never,
243244 this .clearButtonSemanticLabel,
244245 TextInputType ? keyboardType,
@@ -367,6 +368,7 @@ class CupertinoTextField extends StatefulWidget {
367368 this .prefixMode = OverlayVisibilityMode .always,
368369 this .suffix,
369370 this .suffixMode = OverlayVisibilityMode .always,
371+ this .crossAxisAlignment = CrossAxisAlignment .center,
370372 this .clearButtonMode = OverlayVisibilityMode .never,
371373 this .clearButtonSemanticLabel,
372374 TextInputType ? keyboardType,
@@ -516,6 +518,13 @@ class CupertinoTextField extends StatefulWidget {
516518 /// Has no effect when [suffix] is null.
517519 final OverlayVisibilityMode suffixMode;
518520
521+ /// Controls the vertical alignment of the [prefix] and the [suffix] widget in relation to content.
522+ ///
523+ /// Defaults to [CrossAxisAlignment.center] .
524+ ///
525+ /// Has no effect when both the [prefix] and [suffix] are null.
526+ final CrossAxisAlignment crossAxisAlignment;
527+
519528 /// Show an iOS-style clear button to clear the current text entry.
520529 ///
521530 /// Can be made to appear depending on various text states of the
@@ -1213,28 +1222,31 @@ class _CupertinoTextFieldState extends State<CupertinoTextField> with Restoratio
12131222 (true , true ) => widget.suffix ?? _buildClearButton (),
12141223 (false , true ) => _buildClearButton (),
12151224 };
1216- return Row (children: < Widget > [
1217- // Insert a prefix at the front if the prefix visibility mode matches
1218- // the current text state.
1219- if (prefixWidget != null ) prefixWidget,
1220- // In the middle part, stack the placeholder on top of the main EditableText
1221- // if needed.
1222- Expanded (
1223- child: Stack (
1224- // Ideally this should be baseline aligned. However that comes at
1225- // the cost of the ability to compute the intrinsic dimensions of
1226- // this widget.
1227- // See also https://github.com/flutter/flutter/issues/13715.
1228- alignment: AlignmentDirectional .center,
1229- textDirection: widget.textDirection,
1230- children: < Widget > [
1231- if (placeholder != null ) placeholder,
1232- editableText,
1233- ],
1225+ return Row (
1226+ crossAxisAlignment: widget.crossAxisAlignment,
1227+ children: < Widget > [
1228+ // Insert a prefix at the front if the prefix visibility mode matches
1229+ // the current text state.
1230+ if (prefixWidget != null ) prefixWidget,
1231+ // In the middle part, stack the placeholder on top of the main EditableText
1232+ // if needed.
1233+ Expanded (
1234+ child: Stack (
1235+ // Ideally this should be baseline aligned. However that comes at
1236+ // the cost of the ability to compute the intrinsic dimensions of
1237+ // this widget.
1238+ // See also https://github.com/flutter/flutter/issues/13715.
1239+ alignment: AlignmentDirectional .center,
1240+ textDirection: widget.textDirection,
1241+ children: < Widget > [
1242+ if (placeholder != null ) placeholder,
1243+ editableText,
1244+ ],
1245+ ),
12341246 ),
1235- ) ,
1236- if (suffixWidget != null ) suffixWidget
1237- ] );
1247+ if (suffixWidget != null ) suffixWidget ,
1248+ ],
1249+ );
12381250 },
12391251 );
12401252 }
0 commit comments