CupertinoTextField constructor

const CupertinoTextField({Key key, TextEditingController controller, FocusNode focusNode, BoxDecoration decoration: _kDefaultRoundedBorderDecoration, EdgeInsetsGeometry padding: const EdgeInsets.all(6.0), String placeholder, Widget prefix, OverlayVisibilityMode prefixMode: OverlayVisibilityMode.always, Widget suffix, OverlayVisibilityMode suffixMode: OverlayVisibilityMode.always, OverlayVisibilityMode clearButtonMode: OverlayVisibilityMode.never, TextInputType keyboardType, TextInputAction textInputAction, TextCapitalization textCapitalization: TextCapitalization.none, TextStyle style: _kDefaultTextStyle, TextAlign textAlign: TextAlign.start, bool autofocus: false, bool obscureText: false, bool autocorrect: true, int maxLines: 1, int maxLength, bool maxLengthEnforced: true, ValueChanged<String> onChanged, VoidCallback onEditingComplete, ValueChanged<String> onSubmitted, List<TextInputFormatter> inputFormatters, bool enabled, double cursorWidth: 2.0, Radius cursorRadius, Color cursorColor: CupertinoColors.activeBlue, Brightness keyboardAppearance, EdgeInsets scrollPadding: const EdgeInsets.all(20.0) })

Creates an iOS-style text field.

To provide a prefilled text entry, pass in a TextEditingController with an initial value to the controller parameter.

To provide a hint placeholder text that appears when the text entry is empty, pass a String to the placeholder parameter.

The maxLines property can be set to null to remove the restriction on the number of lines. In this mode, the intrinsic height of the widget will grow as the number of lines of text grows. By default, it is 1, meaning this is a single-line text field and will scroll horizontally when overflown. maxLines must not be zero.

See also:

  • maxLength, which discusses the precise meaning of "number of characters" and how it may differ from the intuitive meaning.

Implementation

const CupertinoTextField({
  Key key,
  this.controller,
  this.focusNode,
  this.decoration = _kDefaultRoundedBorderDecoration,
  this.padding = const EdgeInsets.all(6.0),
  this.placeholder,
  this.prefix,
  this.prefixMode = OverlayVisibilityMode.always,
  this.suffix,
  this.suffixMode = OverlayVisibilityMode.always,
  this.clearButtonMode = OverlayVisibilityMode.never,
  TextInputType keyboardType,
  this.textInputAction,
  this.textCapitalization = TextCapitalization.none,
  this.style = _kDefaultTextStyle,
  this.textAlign = TextAlign.start,
  this.autofocus = false,
  this.obscureText = false,
  this.autocorrect = true,
  this.maxLines = 1,
  this.maxLength,
  this.maxLengthEnforced = true,
  this.onChanged,
  this.onEditingComplete,
  this.onSubmitted,
  this.inputFormatters,
  this.enabled,
  this.cursorWidth = 2.0,
  this.cursorRadius,
  this.cursorColor = CupertinoColors.activeBlue,
  this.keyboardAppearance,
  this.scrollPadding = const EdgeInsets.all(20.0),
}) : assert(textAlign != null),
     assert(autofocus != null),
     assert(obscureText != null),
     assert(autocorrect != null),
     assert(maxLengthEnforced != null),
     assert(scrollPadding != null),
     assert(maxLines == null || maxLines > 0),
     assert(maxLength == null || maxLength > 0),
     assert(clearButtonMode != null),
     assert(prefixMode != null),
     assert(suffixMode != null),
     keyboardType = keyboardType ?? (maxLines == 1 ? TextInputType.text : TextInputType.multiline),
     super(key: key);