FormeNumberField constructor

FormeNumberField({
  1. Key? key,
  2. String? name,
  3. double? initialValue,
  4. FormeAsyncValidator<double?>? asyncValidator,
  5. Duration? asyncValidatorDebounce,
  6. AutovalidateMode? autovalidateMode,
  7. bool enabled = true,
  8. FocusNode? focusNode,
  9. FormeFieldInitialized<double?>? onInitialized,
  10. FormeFieldSetter<double?>? onSaved,
  11. FormeFieldStatusChanged<double?>? onStatusChanged,
  12. int? order,
  13. bool quietlyValidate = false,
  14. bool readOnly = false,
  15. bool requestFocusOnUserInteraction = true,
  16. FormeFieldValidationFilter<double?>? validationFilter,
  17. FormeValidator<double?>? validator,
  18. FormeFieldDecorator<double?>? decorator,
  19. bool allowNegative = false,
  20. int decimal = 0,
  21. double? max,
  22. InputDecoration? decoration = const InputDecoration(),
  23. int? maxLines = 1,
  24. TextInputType? keyboardType = TextInputType.number,
  25. bool autofocus = false,
  26. int? minLines,
  27. int? maxLength,
  28. TextStyle? style,
  29. TextInputAction? textInputAction,
  30. TextCapitalization textCapitalization = TextCapitalization.none,
  31. bool obscureText = false,
  32. StrutStyle? strutStyle,
  33. TextAlign textAlign = TextAlign.start,
  34. TextAlignVertical? textAlignVertical,
  35. TextDirection? textDirection,
  36. bool? showCursor,
  37. String obscuringCharacter = '•',
  38. bool autocorrect = true,
  39. SmartDashesType? smartDashesType,
  40. SmartQuotesType? smartQuotesType,
  41. bool enableSuggestions = true,
  42. bool expands = false,
  43. MaxLengthEnforcement? maxLengthEnforcement,
  44. double cursorWidth = 2.0,
  45. double? cursorHeight,
  46. Radius? cursorRadius,
  47. Color? cursorColor,
  48. BoxHeightStyle selectionHeightStyle = BoxHeightStyle.tight,
  49. BoxWidthStyle selectionWidthStyle = BoxWidthStyle.tight,
  50. Brightness? keyboardAppearance,
  51. EdgeInsets scrollPadding = const EdgeInsets.all(20),
  52. DragStartBehavior dragStartBehavior = DragStartBehavior.start,
  53. MouseCursor? mouseCursor,
  54. ScrollPhysics? scrollPhysics,
  55. Iterable<String>? autofillHints,
  56. bool enableInteractiveSelection = true,
  57. VoidCallback? onEditingComplete,
  58. List<TextInputFormatter>? inputFormatters,
  59. AppPrivateCommandCallback? appPrivateCommandCallback,
  60. InputCounterWidgetBuilder? buildCounter,
  61. GestureTapCallback? onTap,
  62. ValueChanged<String>? onSubmitted,
  63. ScrollController? scrollController,
  64. TextSelectionControls? textSelectionControls,
  65. bool enableIMEPersonalizedLearning = true,
  66. TapRegionCallback? onTapOutside,
  67. Clip? clipBehavior,
  68. bool? scribbleEnabled,
  69. EditableTextContextMenuBuilder? contextMenuBuilder = _defaultContextMenuBuilder,
  70. SpellCheckConfiguration? spellCheckConfiguration,
  71. TextMagnifierConfiguration? magnifierConfiguration,
})

Implementation

FormeNumberField({
  super.key,
  super.name,
  super.initialValue,
  super.asyncValidator,
  super.asyncValidatorDebounce,
  super.autovalidateMode,
  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,
  super.decorator,
  this.allowNegative = false,
  this.decimal = 0,
  this.max,
  this.decoration = const InputDecoration(),
  this.maxLines = 1,
  this.keyboardType = TextInputType.number,
  this.autofocus = false,
  this.minLines,
  this.maxLength,
  this.style,
  this.textInputAction,
  this.textCapitalization = TextCapitalization.none,
  this.obscureText = false,
  this.strutStyle,
  this.textAlign = TextAlign.start,
  this.textAlignVertical,
  this.textDirection,
  this.showCursor,
  this.obscuringCharacter = '•',
  this.autocorrect = true,
  this.smartDashesType,
  this.smartQuotesType,
  this.enableSuggestions = true,
  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.autofillHints,
  this.enableInteractiveSelection = true,
  this.onEditingComplete,
  this.inputFormatters,
  this.appPrivateCommandCallback,
  this.buildCounter,
  this.onTap,
  this.onSubmitted,
  this.scrollController,
  this.textSelectionControls,
  this.enableIMEPersonalizedLearning = true,
  this.onTapOutside,
  this.clipBehavior,
  this.scribbleEnabled,
  this.contextMenuBuilder = _defaultContextMenuBuilder,
  this.spellCheckConfiguration,
  this.magnifierConfiguration,
}) : super.allFields(
        builder: (baseState) {
          final bool readOnly = baseState.readOnly;
          final bool enabled = baseState.enabled;
          final _FormeNumberFieldState state =
              baseState as _FormeNumberFieldState;
          final List<TextInputFormatter> formatters = numberFormatters(
              decimal: decimal, allowNegative: allowNegative, max: max);
          if (inputFormatters != null) {
            formatters.addAll(inputFormatters);
          }

          void onChanged(String value) {
            final double? parsed = double.tryParse(value);
            if (parsed != null && parsed != state.value) {
              state.updateController = false;
              state.didChange(parsed);
            } else {
              if (value.isEmpty && state.value != null) {
                state.didChange(null);
              }
            }
          }

          return TextField(
            onChanged: onChanged,
            onTapOutside: onTapOutside,
            clipBehavior: clipBehavior ?? Clip.hardEdge,
            scribbleEnabled: scribbleEnabled ?? true,
            contextMenuBuilder: contextMenuBuilder,
            spellCheckConfiguration: spellCheckConfiguration,
            magnifierConfiguration: magnifierConfiguration ??
                TextMagnifier.adaptiveMagnifierConfiguration,
            enableIMEPersonalizedLearning: enableIMEPersonalizedLearning,
            focusNode: state.focusNode,
            controller: state.textEditingController,
            decoration: decoration?.copyWith(errorText: state.errorText),
            obscureText: obscureText,
            maxLines: maxLines,
            minLines: minLines,
            enabled: enabled,
            readOnly: readOnly,
            onTap: onTap,
            onEditingComplete: onEditingComplete,
            onSubmitted: onSubmitted,
            onAppPrivateCommand: appPrivateCommandCallback,
            textInputAction: textInputAction,
            textCapitalization: textCapitalization,
            style: style,
            strutStyle: strutStyle,
            textAlign: textAlign,
            textAlignVertical: textAlignVertical,
            textDirection: textDirection,
            showCursor: showCursor,
            obscuringCharacter: obscuringCharacter,
            autocorrect: autocorrect,
            smartDashesType: smartDashesType,
            smartQuotesType: smartQuotesType,
            enableSuggestions: enableSuggestions,
            expands: expands,
            cursorWidth: cursorWidth,
            cursorHeight: cursorHeight,
            cursorRadius: cursorRadius,
            cursorColor: cursorColor,
            selectionHeightStyle: selectionHeightStyle,
            selectionWidthStyle: selectionWidthStyle,
            keyboardAppearance: keyboardAppearance,
            scrollPadding: scrollPadding,
            dragStartBehavior: dragStartBehavior,
            mouseCursor: mouseCursor,
            scrollPhysics: scrollPhysics,
            autofillHints: readOnly ? null : autofillHints,
            autofocus: autofocus,
            enableInteractiveSelection: enableInteractiveSelection,
            buildCounter: buildCounter,
            maxLengthEnforcement: maxLengthEnforcement,
            inputFormatters: formatters,
            keyboardType: keyboardType,
            maxLength: maxLength,
            scrollController: scrollController,
            selectionControls: textSelectionControls,
          );
        },
      );