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. TextInputType? keyboardType,
  25. TextStyle? style,
  26. TextEditingController? controller,
  27. TextInputAction? textInputAction,
  28. StrutStyle? strutStyle,
  29. TextDirection? textDirection,
  30. int? maxLength,
  31. VoidCallback? onEditingComplete,
  32. ValueChanged<String?>? onSubmitted,
  33. List<TextInputFormatter>? inputFormatters,
  34. Radius? cursorRadius,
  35. Color? cursorColor,
  36. Brightness? keyboardAppearance,
  37. InputCounterWidgetBuilder? buildCounter,
  38. bool expands = false,
  39. int? minLines,
  40. bool? showCursor,
  41. GestureTapCallback? onTap,
  42. bool enableSuggestions = false,
  43. TextAlignVertical? textAlignVertical,
  44. DragStartBehavior dragStartBehavior = DragStartBehavior.start,
  45. ScrollController? scrollController,
  46. ScrollPhysics? scrollPhysics,
  47. BoxWidthStyle selectionWidthStyle = ui.BoxWidthStyle.tight,
  48. SmartDashesType? smartDashesType,
  49. SmartQuotesType? smartQuotesType,
  50. ToolbarOptions? toolbarOptions,
  51. BoxHeightStyle selectionHeightStyle = ui.BoxHeightStyle.tight,
  52. Iterable<String>? autofillHints,
  53. String obscuringCharacter = '•',
  54. MouseCursor? mouseCursor,
})

Creates a Material Design text field input.

Implementation

FormBuilderTextField({
  Key? key,
  //From Super
  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,
  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.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.toolbarOptions,
  this.selectionHeightStyle = ui.BoxHeightStyle.tight,
  this.autofillHints,
  this.obscuringCharacter = '•',
  this.mouseCursor,
})  : 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(
        key: key,
        initialValue: controller != null ? controller.text : initialValue,
        name: name,
        validator: validator,
        valueTransformer: valueTransformer,
        onChanged: onChanged,
        autovalidateMode: autovalidateMode,
        onSaved: onSaved,
        enabled: enabled,
        onReset: onReset,
        decoration: decoration,
        focusNode: focusNode,
        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,
            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,
            toolbarOptions: toolbarOptions,
            mouseCursor: mouseCursor,
            obscuringCharacter: obscuringCharacter,
            autofillHints: autofillHints,
          );
        },
      );