NumberFormBox<T extends num> constructor
NumberFormBox<T extends num> ({
- Key? key,
- AutovalidateMode? autovalidateMode,
- String? initialValue,
- FormFieldSetter<
String> ? onSaved, - String? restorationId,
- FormFieldValidator<
String> ? 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,
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,
),
),
);
});