FormBuilderTextField constructor

FormBuilderTextField({
  1. Key? key,
  2. required String name,
  3. FormFieldValidator<String>? validator,
  4. String? initialValue,
  5. bool readOnly = false,
  6. InputDecoration decoration = const InputDecoration(),
  7. ValueChanged<String?>? onChanged,
  8. ValueTransformer<String?>? valueTransformer,
  9. bool enabled = true,
  10. FormFieldSetter<String>? onSaved,
  11. AutovalidateMode? autovalidateMode = AutovalidateMode.disabled,
  12. VoidCallback? onReset,
  13. FocusNode? focusNode,
  14. int? maxLines = 1,
  15. bool obscureText = false,
  16. TextCapitalization textCapitalization = TextCapitalization.none,
  17. EdgeInsets scrollPadding = const EdgeInsets.all(20.0),
  18. bool enableInteractiveSelection = true,
  19. MaxLengthEnforcement? maxLengthEnforcement,
  20. TextAlign textAlign = TextAlign.start,
  21. bool autofocus = false,
  22. bool autocorrect = true,
  23. double cursorWidth = 2.0,
  24. double? cursorHeight,
  25. TextInputType? keyboardType,
  26. TextStyle? style,
  27. TextEditingController? controller,
  28. TextInputAction? textInputAction,
  29. StrutStyle? strutStyle,
  30. TextDirection? textDirection,
  31. int? maxLength,
  32. VoidCallback? onEditingComplete,
  33. ValueChanged<String?>? onSubmitted,
  34. List<TextInputFormatter>? inputFormatters,
  35. Radius? cursorRadius,
  36. Color? cursorColor,
  37. Brightness? keyboardAppearance,
  38. InputCounterWidgetBuilder? buildCounter,
  39. bool expands = false,
  40. int? minLines,
  41. bool? showCursor,
  42. GestureTapCallback? onTap,
  43. bool enableSuggestions = false,
  44. TextAlignVertical? textAlignVertical,
  45. DragStartBehavior dragStartBehavior = DragStartBehavior.start,
  46. ScrollController? scrollController,
  47. ScrollPhysics? scrollPhysics,
  48. BoxWidthStyle selectionWidthStyle = ui.BoxWidthStyle.tight,
  49. SmartDashesType? smartDashesType,
  50. SmartQuotesType? smartQuotesType,
  51. BoxHeightStyle selectionHeightStyle = ui.BoxHeightStyle.tight,
  52. Iterable<String>? autofillHints,
  53. String obscuringCharacter = '•',
  54. MouseCursor? mouseCursor,
  55. EditableTextContextMenuBuilder? contextMenuBuilder,
  56. 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,
          );
        },
      );