FormBuilderColorPickerField constructor

FormBuilderColorPickerField(
  1. {Key? key,
  2. required String name,
  3. FormFieldValidator<Color>? validator,
  4. Color? initialValue,
  5. InputDecoration decoration = const InputDecoration(),
  6. ValueChanged<Color?>? onChanged,
  7. ValueTransformer<Color?>? valueTransformer,
  8. bool enabled = true,
  9. FormFieldSetter<Color>? onSaved,
  10. AutovalidateMode? autovalidateMode,
  11. VoidCallback? onReset,
  12. FocusNode? focusNode,
  13. bool readOnly = false,
  14. ColorPickerType colorPickerType = ColorPickerType.colorPicker,
  15. TextCapitalization textCapitalization = TextCapitalization.none,
  16. TextAlign textAlign = TextAlign.start,
  17. TextInputType? keyboardType,
  18. TextInputAction? textInputAction,
  19. TextStyle? style,
  20. StrutStyle? strutStyle,
  21. TextDirection? textDirection,
  22. bool autofocus = false,
  23. bool obscureText = false,
  24. bool autocorrect = true,
  25. MaxLengthEnforcement? maxLengthEnforcement,
  26. int maxLines = 1,
  27. bool expands = false,
  28. bool showCursor = false,
  29. int? minLines,
  30. int? maxLength,
  31. VoidCallback? onEditingComplete,
  32. ValueChanged<Color>? onFieldSubmitted,
  33. List<TextInputFormatter>? inputFormatters,
  34. double cursorWidth = 2.0,
  35. Radius? cursorRadius,
  36. Color? cursorColor,
  37. Brightness? keyboardAppearance,
  38. EdgeInsets scrollPadding = const EdgeInsets.all(20.0),
  39. bool enableInteractiveSelection = true,
  40. InputCounterWidgetBuilder? buildCounter,
  41. TextEditingController? controller,
  42. Widget colorPreviewBuilder(
    1. Color?
    )?,
  43. List<Color> availableColors = const []}
)

Implementation

FormBuilderColorPickerField({
  super.key,
  required super.name,
  super.validator,
  super.initialValue,
  super.decoration,
  super.onChanged,
  super.valueTransformer,
  super.enabled,
  super.onSaved,
  super.autovalidateMode,
  super.onReset,
  super.focusNode,
  bool readOnly = false,
  this.colorPickerType = ColorPickerType.colorPicker,
  this.textCapitalization = TextCapitalization.none,
  this.textAlign = TextAlign.start,
  this.keyboardType,
  this.textInputAction,
  this.style,
  this.strutStyle,
  this.textDirection,
  this.autofocus = false,
  this.obscureText = false,
  this.autocorrect = true,
  this.maxLengthEnforcement,
  this.maxLines = 1,
  this.expands = false,
  this.showCursor = false,
  this.minLines,
  this.maxLength,
  this.onEditingComplete,
  this.onFieldSubmitted,
  this.inputFormatters,
  this.cursorWidth = 2.0,
  this.cursorRadius,
  this.cursorColor,
  this.keyboardAppearance,
  this.scrollPadding = const EdgeInsets.all(20.0),
  this.enableInteractiveSelection = true,
  this.buildCounter,
  this.controller,
  this.colorPreviewBuilder,
  this.availableColors = const [],
}) : super(
        builder: (FormFieldState<Color?> field) {
          final state = field as FormBuilderColorPickerFieldState;
          return TextField(
            style: style,
            decoration: state.decoration.copyWith(
              suffixIcon: colorPreviewBuilder != null
                  ? colorPreviewBuilder(field.value)
                  : LayoutBuilder(
                      key: ObjectKey(state.value),
                      builder: (context, constraints) {
                        return Icon(
                          Icons.circle,
                          key: ObjectKey(state.value),
                          size: constraints.minHeight,
                          color: state.value,
                        );
                      },
                    ),
            ),
            enabled: state.enabled,
            readOnly: readOnly,
            controller: state._effectiveController,
            focusNode: state.effectiveFocusNode,
            textAlign: textAlign,
            autofocus: autofocus,
            expands: expands,
            scrollPadding: scrollPadding,
            autocorrect: autocorrect,
            textCapitalization: textCapitalization,
            keyboardType: keyboardType,
            obscureText: obscureText,
            buildCounter: buildCounter,
            cursorColor: cursorColor,
            cursorRadius: cursorRadius,
            cursorWidth: cursorWidth,
            enableInteractiveSelection: enableInteractiveSelection,
            inputFormatters: inputFormatters,
            keyboardAppearance: keyboardAppearance,
            maxLength: maxLength,
            maxLengthEnforcement: maxLengthEnforcement,
            maxLines: maxLines,
            minLines: minLines,
            onEditingComplete: onEditingComplete,
            showCursor: showCursor,
            strutStyle: strutStyle,
            textDirection: textDirection,
            textInputAction: textInputAction,
          );
        },
      );