CupertinoTextFormFieldRow constructor
- Key? key,
- Widget? prefix,
- EdgeInsetsGeometry? padding,
- TextEditingController? controller,
- String? initialValue,
- FocusNode? focusNode,
- BoxDecoration? decoration,
- TextInputType? keyboardType,
- TextCapitalization textCapitalization = TextCapitalization.none,
- TextInputAction? textInputAction,
- TextStyle? style,
- StrutStyle? strutStyle,
- TextDirection? textDirection,
- TextAlign textAlign = TextAlign.start,
- TextAlignVertical? textAlignVertical,
- bool autofocus = false,
- bool readOnly = false,
- @Deprecated('Use `contextMenuBuilder` instead. ' 'This feature was deprecated after v3.3.0-0.5.pre.') ToolbarOptions? toolbarOptions,
- bool? showCursor,
- String obscuringCharacter = '•',
- bool obscureText = false,
- bool autocorrect = true,
- SmartDashesType? smartDashesType,
- SmartQuotesType? smartQuotesType,
- bool enableSuggestions = true,
- int? maxLines = 1,
- int? minLines,
- bool expands = false,
- int? maxLength,
- ValueChanged<
String> ? onChanged, - GestureTapCallback? onTap,
- VoidCallback? onEditingComplete,
- ValueChanged<
String> ? onFieldSubmitted, - FormFieldSetter<
String> ? onSaved, - FormFieldValidator<
String> ? validator, - List<
TextInputFormatter> ? inputFormatters, - bool? enabled,
- double cursorWidth = 2.0,
- double? cursorHeight,
- Color? cursorColor,
- Brightness? keyboardAppearance,
- EdgeInsets scrollPadding = const EdgeInsets.all(20.0),
- bool enableInteractiveSelection = true,
- TextSelectionControls? selectionControls,
- ScrollPhysics? scrollPhysics,
- Iterable<
String> ? autofillHints, - AutovalidateMode autovalidateMode = AutovalidateMode.disabled,
- String? placeholder,
- TextStyle? placeholderStyle = const TextStyle(fontWeight: FontWeight.w400, color: CupertinoColors.placeholderText),
- EditableTextContextMenuBuilder? contextMenuBuilder = _defaultContextMenuBuilder,
- String? restorationId,
Creates a CupertinoFormRow containing a FormField that wraps a CupertinoTextField.
When a controller is specified, initialValue
must be null (the
default). If controller is null, then a TextEditingController
will be constructed automatically and its text
will be initialized
to initialValue
or the empty string.
The prefix parameter is displayed at the start of the row. Standard iOS guidelines encourage passing a Text widget to prefix to detail the nature of the input.
The padding parameter is used to pad the contents of the row. It is directly passed to CupertinoFormRow. If the padding parameter is null, CupertinoFormRow constructs its own default padding (which is the standard form row padding in iOS.) If no edge insets are intended, explicitly pass EdgeInsets.zero to padding.
For documentation about the various parameters, see the CupertinoTextField class and CupertinoTextField.borderless, the constructor.
Implementation
CupertinoTextFormFieldRow({
super.key,
this.prefix,
this.padding,
this.controller,
String? initialValue,
FocusNode? focusNode,
BoxDecoration? decoration,
TextInputType? keyboardType,
TextCapitalization textCapitalization = TextCapitalization.none,
TextInputAction? textInputAction,
TextStyle? style,
StrutStyle? strutStyle,
TextDirection? textDirection,
TextAlign textAlign = TextAlign.start,
TextAlignVertical? textAlignVertical,
bool autofocus = false,
bool readOnly = false,
@Deprecated(
'Use `contextMenuBuilder` instead. '
'This feature was deprecated after v3.3.0-0.5.pre.',
)
ToolbarOptions? toolbarOptions,
bool? showCursor,
String obscuringCharacter = '•',
bool obscureText = false,
bool autocorrect = true,
SmartDashesType? smartDashesType,
SmartQuotesType? smartQuotesType,
bool enableSuggestions = true,
int? maxLines = 1,
int? minLines,
bool expands = false,
int? maxLength,
this.onChanged,
GestureTapCallback? onTap,
VoidCallback? onEditingComplete,
ValueChanged<String>? onFieldSubmitted,
super.onSaved,
super.validator,
List<TextInputFormatter>? inputFormatters,
bool? enabled,
double cursorWidth = 2.0,
double? cursorHeight,
Color? cursorColor,
Brightness? keyboardAppearance,
EdgeInsets scrollPadding = const EdgeInsets.all(20.0),
bool enableInteractiveSelection = true,
TextSelectionControls? selectionControls,
ScrollPhysics? scrollPhysics,
Iterable<String>? autofillHints,
AutovalidateMode super.autovalidateMode = AutovalidateMode.disabled,
String? placeholder,
TextStyle? placeholderStyle = const TextStyle(
fontWeight: FontWeight.w400,
color: CupertinoColors.placeholderText,
),
EditableTextContextMenuBuilder? contextMenuBuilder = _defaultContextMenuBuilder,
super.restorationId,
}) : assert(initialValue == null || controller == null),
assert(obscuringCharacter.length == 1),
assert(maxLines == null || maxLines > 0),
assert(minLines == null || minLines > 0),
assert(
(maxLines == null) || (minLines == null) || (maxLines >= minLines),
"minLines can't be greater than maxLines",
),
assert(
!expands || (maxLines == null && minLines == null),
'minLines and maxLines must be null when expands is true.',
),
assert(!obscureText || maxLines == 1, 'Obscured fields cannot be multiline.'),
assert(maxLength == null || maxLength > 0),
super(
initialValue: controller?.text ?? initialValue ?? '',
builder: (FormFieldState<String> field) {
final _CupertinoTextFormFieldRowState state =
field as _CupertinoTextFormFieldRowState;
void onChangedHandler(String value) {
field.didChange(value);
onChanged?.call(value);
}
return CupertinoFormRow(
prefix: prefix,
padding: padding,
error: (field.errorText == null) ? null : Text(field.errorText!),
child: UnmanagedRestorationScope(
bucket: field.bucket,
child: CupertinoTextField.borderless(
restorationId: restorationId,
controller: state._effectiveController,
focusNode: focusNode,
keyboardType: keyboardType,
decoration: decoration,
textInputAction: textInputAction,
style: style,
strutStyle: strutStyle,
textAlign: textAlign,
textAlignVertical: textAlignVertical,
textCapitalization: textCapitalization,
textDirection: textDirection,
autofocus: autofocus,
toolbarOptions: toolbarOptions,
readOnly: readOnly,
showCursor: showCursor,
obscuringCharacter: obscuringCharacter,
obscureText: obscureText,
autocorrect: autocorrect,
smartDashesType: smartDashesType,
smartQuotesType: smartQuotesType,
enableSuggestions: enableSuggestions,
maxLines: maxLines,
minLines: minLines,
expands: expands,
maxLength: maxLength,
onChanged: onChangedHandler,
onTap: onTap,
onEditingComplete: onEditingComplete,
onSubmitted: onFieldSubmitted,
inputFormatters: inputFormatters,
enabled: enabled ?? true,
cursorWidth: cursorWidth,
cursorHeight: cursorHeight,
cursorColor: cursorColor,
scrollPadding: scrollPadding,
scrollPhysics: scrollPhysics,
keyboardAppearance: keyboardAppearance,
enableInteractiveSelection: enableInteractiveSelection,
selectionControls: selectionControls,
autofillHints: autofillHints,
placeholder: placeholder,
placeholderStyle: placeholderStyle,
contextMenuBuilder: contextMenuBuilder,
),
),
);
},
);