FormBuilderTouchSpin constructor
FormBuilderTouchSpin({
- Key? key,
- AutovalidateMode? autovalidateMode,
- bool enabled = true,
- FocusNode? focusNode,
- FormFieldSetter<
num> ? onSaved, - FormFieldValidator<
num> ? validator, - InputDecoration decoration = const InputDecoration(),
- num? initialValue,
- required String name,
- ValueChanged<
num?> ? onChanged, - ValueTransformer<
num?> ? valueTransformer, - VoidCallback? onReset,
- Icon addIcon = const Icon(Icons.add),
- NumberFormat? displayFormat,
- Color? iconActiveColor,
- Color? iconDisabledColor,
- EdgeInsets iconPadding = const EdgeInsets.all(4.0),
- double iconSize = 24.0,
- num max = 9999999.0,
- num min = 1.0,
- num step = 1.0,
- Icon subtractIcon = const Icon(Icons.remove),
- 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,
),
);
},
);