NumberFormBox<T extends num> constructor

NumberFormBox<T extends num>({
  1. Key? key,
  2. AutovalidateMode? autovalidateMode,
  3. String? initialValue,
  4. FormFieldSetter<String>? onSaved,
  5. String? restorationId,
  6. FormFieldValidator<String>? validator,
  7. ValueChanged<T?>? onChanged,
  8. FocusNode? focusNode,
  9. bool autofocus = false,
  10. bool? showCursor,
  11. double cursorWidth = 2.0,
  12. double? cursorHeight,
  13. Radius cursorRadius = const Radius.circular(2.0),
  14. Color? cursorColor,
  15. Color? highlightColor,
  16. Color? errorHighlightColor,
  17. String? placeholder,
  18. TextStyle? placeholderStyle,
  19. Widget? leadingIcon,
  20. List<TextInputFormatter>? inputFormatters,
  21. T? value,
  22. bool allowExpressions = false,
  23. bool clearButton = true,
  24. num largeChange = 10,
  25. num smallChange = 1,
  26. num? max,
  27. num? min,
  28. int precision = 2,
  29. SpinButtonPlacementMode mode = SpinButtonPlacementMode.compact,
})

Creates a FormField that contains a NumberBox.

When a controller is specified, initialValue must be null (the default). If controller is null, then a TextEditingController will be constructed automatically and its text will be initialized to initialValue or the empty string.

For documentation about the various parameters, see the NumberBox class and NumberBox.new, the constructor.

Implementation

NumberFormBox({
  super.key,
  super.autovalidateMode,
  super.initialValue,
  super.onSaved,
  super.restorationId,
  super.validator,
  ValueChanged<T?>? onChanged,
  FocusNode? focusNode,
  bool autofocus = false,
  bool? showCursor,
  double cursorWidth = 2.0,
  double? cursorHeight,
  Radius cursorRadius = const Radius.circular(2.0),
  Color? cursorColor,
  Color? highlightColor,
  Color? errorHighlightColor,
  String? placeholder,
  TextStyle? placeholderStyle,
  Widget? leadingIcon,
  List<TextInputFormatter>? inputFormatters,
  T? value,
  bool allowExpressions = false,
  bool clearButton = true,
  num largeChange = 10,
  num smallChange = 1,
  num? max,
  num? min,
  int precision = 2,
  SpinButtonPlacementMode mode = SpinButtonPlacementMode.compact,
}) : super(builder: (FormFieldState<String> field) {
        assert(debugCheckHasFluentTheme(field.context));
        final theme = FluentTheme.of(field.context);
        void onChangedHandler(T? value) {
          field.didChange(value.toString());
          onChanged?.call(value);
        }

        return UnmanagedRestorationScope(
          bucket: field.bucket,
          child: FormRow(
            padding: EdgeInsets.zero,
            error: (field.errorText == null) ? null : Text(field.errorText!),
            child: NumberBox<T>(
              focusNode: focusNode,
              autofocus: autofocus,
              showCursor: showCursor,
              cursorColor: cursorColor,
              cursorHeight: cursorHeight,
              cursorRadius: cursorRadius,
              cursorWidth: cursorWidth,
              onChanged: onChanged == null ? null : onChangedHandler,
              highlightColor: (field.errorText == null)
                  ? highlightColor
                  : errorHighlightColor ??
                      Colors.red.defaultBrushFor(theme.brightness),
              placeholder: placeholder,
              placeholderStyle: placeholderStyle,
              leadingIcon: leadingIcon,
              value: value,
              max: max,
              min: min,
              allowExpressions: allowExpressions,
              clearButton: clearButton,
              largeChange: largeChange,
              smallChange: smallChange,
              precision: precision,
              inputFormatters: inputFormatters,
              mode: mode,
            ),
          ),
        );
      });