FormBuilderTouchSpin constructor Null safety

FormBuilderTouchSpin(
  1. {Key? key,
  2. required String name,
  3. FormFieldValidator<num>? validator,
  4. num? initialValue,
  5. InputDecoration decoration = const InputDecoration(),
  6. ValueChanged<num?>? onChanged,
  7. ValueTransformer<num?>? valueTransformer,
  8. bool enabled = true,
  9. FormFieldSetter<num>? onSaved,
  10. AutovalidateMode autovalidateMode = AutovalidateMode.disabled,
  11. VoidCallback? onReset,
  12. FocusNode? focusNode,
  13. num step = 1.0,
  14. num min = 1.0,
  15. num max = 9999999.0,
  16. double iconSize = 24.0,
  17. NumberFormat? displayFormat,
  18. Icon subtractIcon = const Icon(Icons.remove),
  19. Icon addIcon = const Icon(Icons.add),
  20. EdgeInsets iconPadding = const EdgeInsets.all(4.0),
  21. TextStyle textStyle = const TextStyle(fontSize: 24),
  22. Color? iconActiveColor,
  23. Color? iconDisabledColor}
)

Creates field for selection of a number by tapping on an add or subtract icon

Implementation

FormBuilderTouchSpin({
  Key? key,
  //From Super
  required String name,
  FormFieldValidator<num>? validator,
  num? initialValue,
  InputDecoration decoration = const InputDecoration(),
  ValueChanged<num?>? onChanged,
  ValueTransformer<num?>? valueTransformer,
  bool enabled = true,
  FormFieldSetter<num>? onSaved,
  AutovalidateMode autovalidateMode = AutovalidateMode.disabled,
  VoidCallback? onReset,
  FocusNode? focusNode,
  this.step = 1.0,
  this.min = 1.0,
  this.max = 9999999.0,
  this.iconSize = 24.0,
  this.displayFormat,
  this.subtractIcon = const Icon(Icons.remove),
  this.addIcon = const Icon(Icons.add),
  this.iconPadding = const EdgeInsets.all(4.0),
  this.textStyle = const TextStyle(fontSize: 24),
  this.iconActiveColor,
  this.iconDisabledColor,
}) : super(
        key: key,
        initialValue: initialValue,
        name: name,
        validator: validator,
        valueTransformer: valueTransformer,
        onChanged: onChanged,
        autovalidateMode: autovalidateMode,
        onSaved: onSaved,
        enabled: enabled,
        onReset: onReset,
        decoration: decoration,
        focusNode: focusNode,
        builder: (FormFieldState<num?> field) {
          final state = field as _FormBuilderTouchSpinState;
          final theme = Theme.of(state.context);

          return InputDecorator(
            decoration: state.decoration,
            child: TouchSpin(
              key: ObjectKey(state.value),
              min: min,
              max: max,
              step: step,
              value: field.value ?? 0,
              iconSize: iconSize,
              onChanged: state.enabled
                  ? (value) {
                      state.requestFocus();
                      state.didChange(value);
                    }
                  : null,
              displayFormat: displayFormat,
              textStyle: textStyle,
              addIcon: addIcon,
              subtractIcon: subtractIcon,
              iconActiveColor: iconActiveColor ?? theme.primaryColor,
              iconDisabledColor: iconDisabledColor ?? theme.disabledColor,
              iconPadding: iconPadding,
              enabled: state.enabled,
            ),
          );
        },
      );