FormeNumberField constructor

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

Implementation

FormeNumberField({
  num? initialValue,
  required String name,
  bool readOnly = false,
  Key? key,
  InputDecoration? decoration,
  int? maxLines = 1,
  int? order,
  bool quietlyValidate = false,
  bool autofocus = false,
  int? minLines,
  int? maxLength,
  TextStyle? style,
  ToolbarOptions? toolbarOptions,
  TextInputAction? textInputAction,
  TextCapitalization textCapitalization = TextCapitalization.none,
  bool obscureText = false,
  StrutStyle? strutStyle,
  TextAlign textAlign = TextAlign.start,
  TextAlignVertical? textAlignVertical,
  TextDirection? textDirection,
  bool? showCursor,
  String obscuringCharacter = '•',
  bool autocorrect = true,
  SmartDashesType? smartDashesType,
  SmartQuotesType? smartQuotesType,
  bool enableSuggestions = true,
  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,
  Iterable<String>? autofillHints,
  bool enableInteractiveSelection = true,
  bool enabled = true,
  VoidCallback? onEditingComplete,
  List<TextInputFormatter>? inputFormatters,
  AppPrivateCommandCallback? appPrivateCommandCallback,
  InputCounterWidgetBuilder? buildCounter,
  GestureTapCallback? onTap,
  ValueChanged<num?>? onSubmitted,
  ScrollController? scrollController,
  TextSelectionControls? textSelectionControls,
  Duration? asyncValidatorDebounce,
  AutovalidateMode? autovalidateMode,
  FormeValueChanged<num?>? onValueChanged,
  FormeFocusChanged<num?>? onFocusChanged,
  FormeFieldValidationChanged<num?>? onValidationChanged,
  FormeFieldInitialed<num?>? onInitialed,
  FormeFieldSetter<num?>? onSaved,
  FormeValidator<num?>? validator,
  FormeAsyncValidator<num?>? asyncValidator,
  this.decimal = 0,
  this.max,
  this.allowNegative = false,
  FormeFieldDecorator<num?>? decorator,
  bool registrable = true,
}) : super(
        enabled: enabled,
        registrable: registrable,
        decorator: decorator,
        order: order,
        quietlyValidate: quietlyValidate,
        asyncValidatorDebounce: asyncValidatorDebounce,
        autovalidateMode: autovalidateMode,
        onValueChanged: onValueChanged,
        onFocusChanged: onFocusChanged,
        onValidationChanged: onValidationChanged,
        onInitialed: onInitialed,
        onSaved: onSaved,
        validator: validator,
        asyncValidator: asyncValidator,
        key: key,
        name: name,
        readOnly: readOnly,
        initialValue: initialValue,
        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 num? parsed = num?.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(
            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 == null ? null : (v) => onSubmitted(state.value),
            onChanged: onChanged,
            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,
            toolbarOptions: toolbarOptions,
            enableInteractiveSelection: enableInteractiveSelection,
            buildCounter: buildCounter,
            maxLengthEnforcement: maxLengthEnforcement,
            inputFormatters: formatters,
            keyboardType: TextInputType.number,
            maxLength: maxLength,
            scrollController: scrollController,
            selectionControls: textSelectionControls,
          );
        },
      );