FormeSpinNumberField constructor
FormeSpinNumberField({
- Key? key,
- String? name,
- double? initialValue = 0,
- FormeAsyncValidator<
double> ? asyncValidator, - Duration? asyncValidatorDebounce,
- AutovalidateMode? autovalidateMode,
- FormeFieldDecorator<
double> ? decorator, - bool enabled = true,
- FocusNode? focusNode,
- FormeFieldInitialized<
double> ? onInitialized, - FormeFieldSetter<
double> ? onSaved, - FormeFieldStatusChanged<
double> ? onStatusChanged, - int? order,
- bool quietlyValidate = false,
- bool readOnly = false,
- bool requestFocusOnUserInteraction = true,
- FormeFieldValidationFilter<
double> ? validationFilter, - FormeValidator<
double> ? validator, - bool strictStep = false,
- Duration interval = const Duration(milliseconds: 100),
- double step = 1,
- double acceleration = 0,
- required double max,
- required double min,
- IconConfiguration? increasementIconConfiguration,
- IconConfiguration? decreasementIconConfiguration,
- bool editable = true,
- InputDecoration? decoration = const InputDecoration(),
- int? maxLines = 1,
- bool autofocus = false,
- int? minLines,
- int? maxLength,
- TextStyle? style,
- TextInputAction? textInputAction,
- TextCapitalization textCapitalization = TextCapitalization.none,
- StrutStyle? strutStyle,
- TextAlignVertical? textAlignVertical,
- TextDirection? textDirection,
- bool? showCursor,
- SmartDashesType? smartDashesType,
- SmartQuotesType? smartQuotesType,
- bool expands = false,
- MaxLengthEnforcement? maxLengthEnforcement,
- double cursorWidth = 2.0,
- double? cursorHeight,
- Radius? cursorRadius,
- Color? cursorColor,
- BoxHeightStyle selectionHeightStyle = BoxHeightStyle.tight,
- BoxWidthStyle selectionWidthStyle = BoxWidthStyle.tight,
- Brightness? keyboardAppearance,
- EdgeInsets scrollPadding = const EdgeInsets.all(20),
- DragStartBehavior dragStartBehavior = DragStartBehavior.start,
- MouseCursor? mouseCursor,
- ScrollPhysics? scrollPhysics,
- bool enableInteractiveSelection = true,
- VoidCallback? onEditingComplete,
- List<
TextInputFormatter> ? inputFormatters, - AppPrivateCommandCallback? appPrivateCommandCallback,
- GestureTapCallback? onTap,
- ValueChanged<
double> ? onSubmitted, - ScrollController? scrollController,
- TextSelectionControls? textSelectionControls,
- TapRegionCallback? onTapOutside,
- Clip? clipBehavior,
- bool? scribbleEnabled,
- EditableTextContextMenuBuilder? contextMenuBuilder = _defaultContextMenuBuilder,
- SpellCheckConfiguration? spellCheckConfiguration,
- TextMagnifierConfiguration? magnifierConfiguration,
Implementation
FormeSpinNumberField({
super.key,
super.name,
double? initialValue = 0,
super.asyncValidator,
super.asyncValidatorDebounce,
super.autovalidateMode,
super.decorator,
super.enabled = true,
super.focusNode,
super.onInitialized,
super.onSaved,
super.onStatusChanged,
super.order,
super.quietlyValidate = false,
super.readOnly = false,
super.requestFocusOnUserInteraction = true,
super.validationFilter,
super.validator,
this.strictStep = false,
this.interval = const Duration(milliseconds: 100),
this.step = 1,
this.acceleration = 0,
required this.max,
required this.min,
this.increasementIconConfiguration,
this.decreasementIconConfiguration,
this.editable = true,
this.decoration = const InputDecoration(),
this.maxLines = 1,
this.autofocus = false,
this.minLines,
this.maxLength,
this.style,
this.textInputAction,
this.textCapitalization = TextCapitalization.none,
this.strutStyle,
this.textAlignVertical,
this.textDirection,
this.showCursor,
this.smartDashesType,
this.smartQuotesType,
this.expands = false,
this.maxLengthEnforcement,
this.cursorWidth = 2.0,
this.cursorHeight,
this.cursorRadius,
this.cursorColor,
this.selectionHeightStyle = BoxHeightStyle.tight,
this.selectionWidthStyle = BoxWidthStyle.tight,
this.keyboardAppearance,
this.scrollPadding = const EdgeInsets.all(20),
this.dragStartBehavior = DragStartBehavior.start,
this.mouseCursor,
this.scrollPhysics,
this.enableInteractiveSelection = true,
this.onEditingComplete,
this.inputFormatters,
this.appPrivateCommandCallback,
this.onTap,
this.onSubmitted,
this.scrollController,
this.textSelectionControls,
this.onTapOutside,
this.clipBehavior,
this.scribbleEnabled,
this.contextMenuBuilder = _defaultContextMenuBuilder,
this.spellCheckConfiguration,
this.magnifierConfiguration,
}) : super.allFields(
initialValue: initialValue == null
? min
: initialValue < min || initialValue > max
? min
: initialValue,
builder: (baseState) {
final bool readOnly = baseState.readOnly;
final bool enabled = baseState.enabled;
final _FormeSpinNumberFieldState state =
baseState as _FormeSpinNumberFieldState;
final InputDecoration finalDecoration =
(decoration ?? const InputDecoration()).copyWith(
errorText: state.errorText,
prefixIcon: IconButton(
iconSize: decreasementIconConfiguration?.iconSize ?? 24,
visualDensity: decreasementIconConfiguration?.visualDensity,
padding: decreasementIconConfiguration?.padding ??
const EdgeInsets.all(8.0),
alignment: decreasementIconConfiguration?.alignment ??
Alignment.center,
splashRadius: decreasementIconConfiguration?.splashRadius,
color: decreasementIconConfiguration?.color,
focusColor: decreasementIconConfiguration?.focusColor,
hoverColor: decreasementIconConfiguration?.hoverColor,
highlightColor: decreasementIconConfiguration?.highlightColor,
splashColor: decreasementIconConfiguration?.splashColor,
disabledColor: decreasementIconConfiguration?.disabledColor,
tooltip: decreasementIconConfiguration?.tooltip,
enableFeedback:
decreasementIconConfiguration?.enableFeedback ?? true,
constraints: decreasementIconConfiguration?.constraints,
onPressed: readOnly ? null : state.subtract,
icon: GestureDetector(
onLongPress: readOnly
? null
: () {
state.startAccelerate(_CalcType.subtract);
},
onLongPressUp: state.stopAccelerate,
child: decreasementIconConfiguration?.icon ??
const Icon(Icons.remove),
),
),
suffixIcon: IconButton(
iconSize: increasementIconConfiguration?.iconSize ?? 24,
visualDensity: increasementIconConfiguration?.visualDensity,
padding: increasementIconConfiguration?.padding ??
const EdgeInsets.all(8.0),
alignment: increasementIconConfiguration?.alignment ??
Alignment.center,
splashRadius: increasementIconConfiguration?.splashRadius,
color: increasementIconConfiguration?.color,
focusColor: increasementIconConfiguration?.focusColor,
hoverColor: increasementIconConfiguration?.hoverColor,
highlightColor: increasementIconConfiguration?.highlightColor,
splashColor: increasementIconConfiguration?.splashColor,
disabledColor: increasementIconConfiguration?.disabledColor,
tooltip: increasementIconConfiguration?.tooltip,
enableFeedback:
increasementIconConfiguration?.enableFeedback ?? true,
constraints: increasementIconConfiguration?.constraints,
onPressed: readOnly ? null : state.add,
icon: GestureDetector(
onLongPress: readOnly
? null
: () {
state.startAccelerate(_CalcType.plus);
},
onLongPressUp: state.stopAccelerate,
child: increasementIconConfiguration?.icon ??
const Icon(Icons.add),
),
),
);
return TextField(
decoration: finalDecoration,
inputFormatters: state.numberFormatters(
decimal: state.decimal,
allowNegative: min < 0,
max: max.toDouble()),
controller: state.textEditingController,
focusNode: state.focusNode,
onSubmitted: readOnly
? null
: (v) {
onSubmitted?.call(state.value);
},
enabled: enabled,
readOnly: !editable || readOnly,
onChanged: state.onTextFieldChange,
textAlign: TextAlign.center,
onTapOutside: onTapOutside,
clipBehavior: clipBehavior ?? Clip.hardEdge,
scribbleEnabled: scribbleEnabled ?? true,
contextMenuBuilder: contextMenuBuilder,
spellCheckConfiguration: spellCheckConfiguration,
magnifierConfiguration: magnifierConfiguration ??
TextMagnifier.adaptiveMagnifierConfiguration,
maxLines: maxLines,
minLines: minLines,
onTap: onTap,
onEditingComplete: onEditingComplete,
onAppPrivateCommand: appPrivateCommandCallback,
textInputAction: textInputAction,
textCapitalization: textCapitalization,
style: style,
strutStyle: strutStyle,
textAlignVertical: textAlignVertical,
textDirection: textDirection,
showCursor: showCursor,
smartDashesType: smartDashesType,
smartQuotesType: smartQuotesType,
expands: expands,
cursorWidth: cursorWidth,
cursorHeight: cursorHeight,
cursorRadius: cursorRadius,
cursorColor: cursorColor,
selectionHeightStyle: selectionHeightStyle,
selectionWidthStyle: selectionWidthStyle,
keyboardAppearance: keyboardAppearance,
scrollPadding: scrollPadding,
dragStartBehavior: dragStartBehavior,
mouseCursor: mouseCursor,
scrollPhysics: scrollPhysics,
autofocus: autofocus,
enableInteractiveSelection: enableInteractiveSelection,
maxLengthEnforcement: maxLengthEnforcement,
keyboardType: TextInputType.number,
maxLength: maxLength,
scrollController: scrollController,
selectionControls: textSelectionControls,
);
},
);