FormeCupertinoNumberField constructor

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

Implementation

FormeCupertinoNumberField({
  super.key,
  super.name,
  super.initialValue,
  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.allowNegative = false,
  this.decimal = 0,
  this.max,
  this.decoration = _kDefaultRoundedBorderDecoration,
  this.padding = const EdgeInsets.all(7.0),
  this.placeholder,
  this.placeholderStyle = const TextStyle(
    fontWeight: FontWeight.w400,
    color: CupertinoColors.placeholderText,
  ),
  this.prefix,
  this.prefixMode = OverlayVisibilityMode.always,
  this.suffix,
  this.suffixMode = OverlayVisibilityMode.always,
  this.clearButtonMode = OverlayVisibilityMode.never,
  this.keyboardType = TextInputType.number,
  this.textInputAction,
  this.textCapitalization = TextCapitalization.none,
  this.style,
  this.strutStyle,
  this.textAlign = TextAlign.start,
  this.textAlignVertical,
  this.showCursor,
  this.autofocus = false,
  this.obscuringCharacter = '•',
  this.obscureText = false,
  this.autocorrect = true,
  this.smartDashesType,
  this.smartQuotesType,
  this.enableSuggestions = true,
  this.minLines,
  this.expands = false,
  this.maxLength,
  this.maxLengthEnforcement,
  this.onEditingComplete,
  this.onSubmitted,
  this.inputFormatters,
  this.cursorWidth = 2.0,
  this.cursorHeight,
  this.cursorRadius = const Radius.circular(2.0),
  this.cursorColor,
  this.selectionHeightStyle = BoxHeightStyle.tight,
  this.selectionWidthStyle = BoxWidthStyle.tight,
  this.keyboardAppearance,
  this.scrollPadding = const EdgeInsets.all(20.0),
  this.enableInteractiveSelection,
  this.selectionControls,
  this.dragStartBehavior = DragStartBehavior.start,
  this.scrollController,
  this.scrollPhysics,
  this.onTap,
  this.autofillHints,
  this.enableIMEPersonalizedLearning = true,
  this.textDirection,
  this.clipBehavior = Clip.hardEdge,
  this.scribbleEnabled = true,
  this.onTapOutside,
  this.contextMenuBuilder = _defaultContextMenuBuilder,
  this.spellCheckConfiguration,
  this.magnifierConfiguration,
  this.maxLines = 1,
}) : super.allFields(builder: (baseState) {
        final _FormeCupertinoNumberFieldState state =
            baseState as _FormeCupertinoNumberFieldState;

        final List<TextInputFormatter> formatters =
            FormeNumberField.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 CupertinoTextField(
          onChanged: onChanged,
          controller: state.textEditingController,
          focusNode: state.focusNode,
          decoration: decoration,
          padding: padding,
          placeholder: placeholder,
          placeholderStyle: placeholderStyle,
          prefix: prefix,
          prefixMode: prefixMode,
          suffix: suffix,
          suffixMode: suffixMode,
          clearButtonMode: clearButtonMode,
          keyboardType: keyboardType,
          textInputAction: textInputAction,
          textCapitalization: textCapitalization,
          style: style,
          strutStyle: strutStyle,
          textAlign: textAlign,
          textAlignVertical: textAlignVertical,
          textDirection: textDirection,
          readOnly: state.readOnly,
          showCursor: showCursor,
          autofocus: autofocus,
          obscuringCharacter: obscuringCharacter,
          obscureText: obscureText,
          autocorrect: autocorrect,
          smartDashesType: smartDashesType,
          smartQuotesType: smartQuotesType,
          enableSuggestions: enableSuggestions,
          maxLines: maxLines,
          minLines: minLines,
          expands: expands,
          maxLength: maxLength,
          maxLengthEnforcement: maxLengthEnforcement,
          onEditingComplete: onEditingComplete,
          onSubmitted: onSubmitted,
          onTapOutside: onTapOutside,
          inputFormatters: formatters,
          enabled: state.enabled,
          cursorWidth: cursorWidth,
          cursorHeight: cursorHeight,
          cursorRadius: cursorRadius,
          cursorColor: cursorColor,
          selectionHeightStyle: selectionHeightStyle,
          selectionWidthStyle: selectionWidthStyle,
          keyboardAppearance: keyboardAppearance,
          scrollPadding: scrollPadding,
          dragStartBehavior: dragStartBehavior,
          enableInteractiveSelection: enableInteractiveSelection,
          selectionControls: selectionControls,
          onTap: onTap,
          scrollController: scrollController,
          scrollPhysics: scrollPhysics,
          autofillHints: autofillHints,
          clipBehavior: clipBehavior,
          scribbleEnabled: scribbleEnabled,
          enableIMEPersonalizedLearning: enableIMEPersonalizedLearning,
          contextMenuBuilder: contextMenuBuilder,
          spellCheckConfiguration: spellCheckConfiguration,
          magnifierConfiguration: magnifierConfiguration,
        );
      });