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. bool readOnly = false,
  15. int? maxLines = 1,
  16. bool obscureText = false,
  17. TextCapitalization textCapitalization = TextCapitalization.none,
  18. EdgeInsets scrollPadding = const EdgeInsets.all(20.0),
  19. bool enableInteractiveSelection = true,
  20. MaxLengthEnforcement? maxLengthEnforcement,
  21. TextAlign textAlign = TextAlign.start,
  22. bool autofocus = false,
  23. bool autocorrect = true,
  24. double cursorWidth = 2.0,
  25. double? cursorHeight,
  26. TextInputType? keyboardType,
  27. TextStyle? style,
  28. TextEditingController? controller,
  29. TextInputAction? textInputAction,
  30. StrutStyle? strutStyle,
  31. TextDirection? textDirection,
  32. int? maxLength,
  33. VoidCallback? onEditingComplete,
  34. ValueChanged<String?>? onSubmitted,
  35. List<TextInputFormatter>? inputFormatters,
  36. Radius? cursorRadius,
  37. Color? cursorColor,
  38. Brightness? keyboardAppearance,
  39. InputCounterWidgetBuilder? buildCounter,
  40. bool expands = false,
  41. int? minLines,
  42. bool? showCursor,
  43. GestureTapCallback? onTap,
  44. TapRegionCallback? onTapOutside,
  45. bool enableSuggestions = false,
  46. TextAlignVertical? textAlignVertical,
  47. DragStartBehavior dragStartBehavior = DragStartBehavior.start,
  48. ScrollController? scrollController,
  49. ScrollPhysics? scrollPhysics,
  50. BoxWidthStyle selectionWidthStyle = ui.BoxWidthStyle.tight,
  51. SmartDashesType? smartDashesType,
  52. SmartQuotesType? smartQuotesType,
  53. BoxHeightStyle selectionHeightStyle = ui.BoxHeightStyle.tight,
  54. Iterable<String>? autofillHints,
  55. String obscuringCharacter = '•',
  56. MouseCursor? mouseCursor,
  57. EditableTextContextMenuBuilder? contextMenuBuilder = _defaultContextMenuBuilder,
  58. TextMagnifierConfiguration? magnifierConfiguration,
  59. ContentInsertionConfiguration? contentInsertionConfiguration,
  60. SpellCheckConfiguration? spellCheckConfiguration,
})

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,
  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 = 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 = _defaultContextMenuBuilder,
  this.magnifierConfiguration,
  this.contentInsertionConfiguration,
  this.spellCheckConfiguration,
})  : 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,
          );
        },
      );