FormBuilderTextField constructor

FormBuilderTextField({
  1. Key? key,
  2. required String name,
  3. FormFieldValidator<String>? validator,
  4. InputDecoration decoration = const InputDecoration(),
  5. ValueChanged<String?>? onChanged,
  6. ValueTransformer<String?>? valueTransformer,
  7. bool enabled = true,
  8. FormFieldSetter<String>? onSaved,
  9. AutovalidateMode? autovalidateMode = AutovalidateMode.disabled,
  10. VoidCallback? onReset,
  11. FocusNode? focusNode,
  12. String? restorationId,
  13. String? initialValue,
  14. FormFieldErrorBuilder? errorBuilder,
  15. bool readOnly = false,
  16. int? maxLines = 1,
  17. bool obscureText = false,
  18. TextCapitalization textCapitalization = TextCapitalization.none,
  19. EdgeInsets scrollPadding = const EdgeInsets.all(20.0),
  20. bool enableInteractiveSelection = true,
  21. MaxLengthEnforcement? maxLengthEnforcement,
  22. TextAlign textAlign = TextAlign.start,
  23. bool autofocus = false,
  24. bool autocorrect = true,
  25. double cursorWidth = 2.0,
  26. double? cursorHeight,
  27. TextInputType? keyboardType,
  28. TextStyle? style,
  29. TextEditingController? controller,
  30. TextInputAction? textInputAction,
  31. StrutStyle? strutStyle,
  32. TextDirection? textDirection,
  33. int? maxLength,
  34. VoidCallback? onEditingComplete,
  35. ValueChanged<String?>? onSubmitted,
  36. List<TextInputFormatter>? inputFormatters,
  37. Radius? cursorRadius,
  38. Color? cursorColor,
  39. Brightness? keyboardAppearance,
  40. InputCounterWidgetBuilder? buildCounter,
  41. bool expands = false,
  42. int? minLines,
  43. bool? showCursor,
  44. GestureTapCallback? onTap,
  45. TapRegionCallback? onTapOutside,
  46. bool enableSuggestions = true,
  47. TextAlignVertical? textAlignVertical,
  48. DragStartBehavior dragStartBehavior = DragStartBehavior.start,
  49. ScrollController? scrollController,
  50. ScrollPhysics? scrollPhysics,
  51. BoxWidthStyle selectionWidthStyle = ui.BoxWidthStyle.tight,
  52. SmartDashesType? smartDashesType,
  53. SmartQuotesType? smartQuotesType,
  54. BoxHeightStyle selectionHeightStyle = ui.BoxHeightStyle.tight,
  55. Iterable<String>? autofillHints,
  56. String obscuringCharacter = '•',
  57. MouseCursor? mouseCursor,
  58. EditableTextContextMenuBuilder? contextMenuBuilder = _defaultContextMenuBuilder,
  59. TextMagnifierConfiguration? magnifierConfiguration,
  60. ContentInsertionConfiguration? contentInsertionConfiguration,
  61. SpellCheckConfiguration? spellCheckConfiguration,
  62. Clip clipBehavior = Clip.hardEdge,
  63. @Deprecated('This property will be removed in the next Flutter stable versions. ' 'Use FocusNode.canRequestFocus instead. ' 'Ref: https://docs.flutter.dev/release/breaking-changes/can-request-focus') bool canRequestFocus = true,
  64. Color? cursorErrorColor,
  65. bool? cursorOpacityAnimates,
  66. bool enableIMEPersonalizedLearning = true,
  67. Object groupId = EditableText,
  68. AppPrivateCommandCallback? onAppPrivateCommand,
  69. bool onTapAlwaysCalled = false,
  70. @Deprecated('Use `stylusHandwritingEnabled` instead. ' 'This feature was deprecated after v3.27.0-0.2.pre.') bool scribbleEnabled = true,
  71. bool stylusHandwritingEnabled = EditableText.defaultStylusHandwritingEnabled,
  72. TextSelectionControls? selectionControls,
  73. WidgetStatesController? statesController,
  74. UndoHistoryController? undoController,
})

Creates a Material Design text field input.

Implementation

FormBuilderTextField({
  super.key,
  required super.name,
  super.validator,
  super.decoration,
  super.onChanged,
  super.valueTransformer,
  super.enabled,
  super.onSaved,
  super.autovalidateMode = AutovalidateMode.disabled,
  super.onReset,
  super.focusNode,
  super.restorationId,
  String? initialValue,
  super.errorBuilder,
  this.readOnly = false,
  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.onTapOutside,
  this.enableSuggestions = true,
  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 = _defaultContextMenuBuilder,
  this.magnifierConfiguration,
  this.contentInsertionConfiguration,
  this.spellCheckConfiguration,
  this.clipBehavior = Clip.hardEdge,
  @Deprecated(
    'This property will be removed in the next Flutter stable versions. '
    'Use FocusNode.canRequestFocus instead. '
    'Ref: https://docs.flutter.dev/release/breaking-changes/can-request-focus',
  )
  this.canRequestFocus = true,
  this.cursorErrorColor,
  this.cursorOpacityAnimates,
  this.enableIMEPersonalizedLearning = true,
  this.groupId = EditableText,
  this.onAppPrivateCommand,
  this.onTapAlwaysCalled = false,
  @Deprecated(
    'Use `stylusHandwritingEnabled` instead. '
    'This feature was deprecated after v3.27.0-0.2.pre.',
  )
  this.scribbleEnabled = true,
  this.stylusHandwritingEnabled =
      EditableText.defaultStylusHandwritingEnabled,
  this.selectionControls,
  this.statesController,
  this.undoController,
}) : 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;

         return TextField(
           restorationId: restorationId,
           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,
           onTapOutside: onTapOutside,
           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,
           contentInsertionConfiguration: contentInsertionConfiguration,
           spellCheckConfiguration: spellCheckConfiguration,
           clipBehavior: clipBehavior,
           canRequestFocus: canRequestFocus,
           cursorErrorColor: cursorErrorColor,
           cursorOpacityAnimates: cursorOpacityAnimates,
           enableIMEPersonalizedLearning: enableIMEPersonalizedLearning,
           groupId: groupId,
           onAppPrivateCommand: onAppPrivateCommand,
           onTapAlwaysCalled: onTapAlwaysCalled,
           stylusHandwritingEnabled: stylusHandwritingEnabled,
           selectionControls: selectionControls,
           statesController: statesController,
           undoController: undoController,
         );
       },
     );