FormBuilderTextField constructor
FormBuilderTextField({
- Key? key,
- required String name,
- FormFieldValidator<
String> ? validator, - String? initialValue,
- bool readOnly = false,
- InputDecoration decoration = const InputDecoration(),
- ValueChanged<
String?> ? onChanged, - ValueTransformer<
String?> ? valueTransformer, - bool enabled = true,
- FormFieldSetter<
String> ? onSaved, - AutovalidateMode? autovalidateMode = AutovalidateMode.disabled,
- VoidCallback? onReset,
- FocusNode? focusNode,
- int? maxLines = 1,
- bool obscureText = false,
- TextCapitalization textCapitalization = TextCapitalization.none,
- EdgeInsets scrollPadding = const EdgeInsets.all(20.0),
- bool enableInteractiveSelection = true,
- MaxLengthEnforcement? maxLengthEnforcement,
- TextAlign textAlign = TextAlign.start,
- bool autofocus = false,
- bool autocorrect = true,
- double cursorWidth = 2.0,
- double? cursorHeight,
- TextInputType? keyboardType,
- TextStyle? style,
- TextEditingController? controller,
- TextInputAction? textInputAction,
- StrutStyle? strutStyle,
- TextDirection? textDirection,
- int? maxLength,
- VoidCallback? onEditingComplete,
- ValueChanged<
String?> ? onSubmitted, - List<
TextInputFormatter> ? inputFormatters, - Radius? cursorRadius,
- Color? cursorColor,
- Brightness? keyboardAppearance,
- InputCounterWidgetBuilder? buildCounter,
- bool expands = false,
- int? minLines,
- bool? showCursor,
- GestureTapCallback? onTap,
- bool enableSuggestions = false,
- TextAlignVertical? textAlignVertical,
- DragStartBehavior dragStartBehavior = DragStartBehavior.start,
- ScrollController? scrollController,
- ScrollPhysics? scrollPhysics,
- BoxWidthStyle selectionWidthStyle = ui.BoxWidthStyle.tight,
- SmartDashesType? smartDashesType,
- SmartQuotesType? smartQuotesType,
- BoxHeightStyle selectionHeightStyle = ui.BoxHeightStyle.tight,
- Iterable<
String> ? autofillHints, - String obscuringCharacter = '•',
- MouseCursor? mouseCursor,
- EditableTextContextMenuBuilder? contextMenuBuilder,
- TextMagnifierConfiguration? magnifierConfiguration,
Creates a Material Design text field input.
Implementation
FormBuilderTextField({
super.key,
required super.name,
super.validator,
String? initialValue,
bool readOnly = false,
super.decoration,
super.onChanged,
super.valueTransformer,
super.enabled,
super.onSaved,
super.autovalidateMode = AutovalidateMode.disabled,
super.onReset,
super.focusNode,
this.maxLines = 1,
this.obscureText = false,
this.textCapitalization = TextCapitalization.none,
this.scrollPadding = const EdgeInsets.all(20.0),
this.enableInteractiveSelection = true,
this.maxLengthEnforcement,
this.textAlign = TextAlign.start,
this.autofocus = false,
this.autocorrect = true,
this.cursorWidth = 2.0,
this.cursorHeight,
this.keyboardType,
this.style,
this.controller,
this.textInputAction,
this.strutStyle,
this.textDirection,
this.maxLength,
this.onEditingComplete,
this.onSubmitted,
this.inputFormatters,
this.cursorRadius,
this.cursorColor,
this.keyboardAppearance,
this.buildCounter,
this.expands = false,
this.minLines,
this.showCursor,
this.onTap,
this.enableSuggestions = false,
this.textAlignVertical,
this.dragStartBehavior = DragStartBehavior.start,
this.scrollController,
this.scrollPhysics,
this.selectionWidthStyle = ui.BoxWidthStyle.tight,
this.smartDashesType,
this.smartQuotesType,
this.selectionHeightStyle = ui.BoxHeightStyle.tight,
this.autofillHints,
this.obscuringCharacter = '•',
this.mouseCursor,
this.contextMenuBuilder,
this.magnifierConfiguration,
}) : assert(initialValue == null || controller == null),
assert(minLines == null || minLines > 0),
assert(maxLines == null || maxLines > 0),
assert(
(minLines == null) || (maxLines == null) || (maxLines >= minLines),
'minLines can\'t be greater than maxLines',
),
assert(
!expands || (minLines == null && maxLines == 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 != null ? controller.text : initialValue,
builder: (FormFieldState<String?> field) {
final state = field as _FormBuilderTextFieldState;
/*final effectiveDecoration = (decoration ?? const InputDecoration())
.applyDefaults(Theme.of(field.context).inputDecorationTheme);*/
return TextField(
controller: state._effectiveController,
focusNode: state.effectiveFocusNode,
decoration: state.decoration,
keyboardType: keyboardType,
textInputAction: textInputAction,
style: style,
strutStyle: strutStyle,
textAlign: textAlign,
textAlignVertical: textAlignVertical,
textDirection: textDirection,
textCapitalization: textCapitalization,
autofocus: autofocus,
readOnly: readOnly,
showCursor: showCursor,
obscureText: obscureText,
autocorrect: autocorrect,
enableSuggestions: enableSuggestions,
maxLengthEnforcement: maxLengthEnforcement,
maxLines: maxLines,
minLines: minLines,
expands: expands,
maxLength: maxLength,
onTap: onTap,
onEditingComplete: onEditingComplete,
onSubmitted: onSubmitted,
inputFormatters: inputFormatters,
enabled: state.enabled,
cursorWidth: cursorWidth,
cursorHeight: cursorHeight,
cursorRadius: cursorRadius,
cursorColor: cursorColor,
scrollPadding: scrollPadding,
keyboardAppearance: keyboardAppearance,
enableInteractiveSelection: enableInteractiveSelection,
buildCounter: buildCounter,
dragStartBehavior: dragStartBehavior,
scrollController: scrollController,
scrollPhysics: scrollPhysics,
selectionHeightStyle: selectionHeightStyle,
selectionWidthStyle: selectionWidthStyle,
smartDashesType: smartDashesType,
smartQuotesType: smartQuotesType,
mouseCursor: mouseCursor,
contextMenuBuilder: contextMenuBuilder,
obscuringCharacter: obscuringCharacter,
autofillHints: autofillHints,
magnifierConfiguration: magnifierConfiguration,
);
},
);