FormBuilderTouchSpin constructor

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

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

Implementation

FormBuilderTouchSpin({
  super.key,
  super.autovalidateMode,
  super.enabled,
  super.focusNode,
  super.onSaved,
  super.validator,
  super.decoration,
  super.initialValue,
  required super.name,
  super.onChanged,
  super.valueTransformer,
  super.onReset,
  this.addIcon = const Icon(Icons.add),
  this.displayFormat,
  this.iconActiveColor,
  this.iconDisabledColor,
  this.iconPadding = const EdgeInsets.all(4.0),
  this.iconSize = 24.0,
  this.max = 9999999.0,
  this.min = 1.0,
  this.step = 1.0,
  this.subtractIcon = const Icon(Icons.remove),
  this.textStyle = const TextStyle(fontSize: 24),
}) : super(
        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.didChange(value);
                    }
                  : null,
              displayFormat: displayFormat,
              textStyle: textStyle,
              addIcon: addIcon,
              subtractIcon: subtractIcon,
              iconActiveColor: iconActiveColor ?? theme.primaryColor,
              iconDisabledColor: iconDisabledColor ?? theme.disabledColor,
              iconPadding: iconPadding,
              enabled: state.enabled,
            ),
          );
        },
      );