NumberField class

A numeric input with fixed 40px steppers on both sides.

The field is a uniform-height Input (same size as other fields) with tabular figures and a digits-only formatter; the prefix stepper decrements, the suffix increments, each by step, clamped to minValue/maxValue (steppers disable at the bounds). Typing parses through num.tryParse — invalid text leaves the last valid value.

NumberField(
  value: quantity,
  minValue: 1,
  maxValue: 99,
  onChanged: (v) => setState(() => quantity = v),
)
Inheritance

Constructors

NumberField({Key? key, required num value, num? minValue, num? maxValue, num step = 1, ValueChanged<num>? onChanged, NumberFieldVariant? variant, RadiusToken? radius, Widget? label, Widget? description, Widget? errorMessage, bool isInvalid = false, bool disabled = false, bool fullWidth = false, FormFieldValidator<num>? validator, FormFieldSetter<num>? onSaved, FormFieldErrorBuilder? errorBuilder, String? forceErrorText, VoidCallback? onReset, AutovalidateMode autovalidateMode = AutovalidateMode.onUserInteraction})
Creates a NumberField.
const

Properties

autovalidateMode → AutovalidateMode
When the validator runs without being asked.
final
description → Widget?
Helper text shown below the field.
final
disabled → bool
Disables the field.
final
errorBuilder → FormFieldErrorBuilder?
Builds the widget that shows the validator's error text.
final
errorMessage → Widget?
Error text shown below the field while it is invalid.
final
forceErrorText → String?
Error text that is shown whatever the validator returns.
final
fullWidth → bool
Whether the field stretches to the full available width.
final
hashCode → int
The hash code for this object.
no setterinherited
isInvalid → bool
Whether the field is drawn in its invalid state.
final
key → Key?
Controls how one widget replaces another widget in the tree.
finalinherited
label → Widget?
Label shown above the field.
final
maxValue → num?
Upper clamp for steppers and validation.
final
minValue → num?
Lower clamp for steppers and validation.
final
onChanged → ValueChanged<num>?
Reports every committed change (stepper taps and valid typing).
final
onReset → VoidCallback?
Called when the enclosing form resets.
final
onSaved → FormFieldSetter<num>?
Called with the field's value when the enclosing form saves.
final
radius → RadiusToken?
Corner radius token. Defaults to FieldDefaults.radius, then RadiusToken.field.
final
runtimeType → Type
A representation of the runtime type of the object.
no setterinherited
step → num
Amount added/removed per stepper tap.
final
validator → FormFieldValidator<num>?
Returns an error message when the value is invalid, or null when it is valid. It runs when the form validates and as autovalidateMode directs.
final
value → num
Current numeric value; also the reset target.
final
variant → NumberFieldVariant?
Visual treatment for the field. Defaults to FieldDefaults.variant, then NumberFieldVariant.outline.
final

Methods

createElement() → StatefulElement
Creates a StatefulElement to manage this widget's location in the tree.
inherited
createState() → State<NumberField>
Creates the mutable state for this widget at a given location in the tree.
override
debugDescribeChildren() → List<DiagnosticsNode>
Returns a list of DiagnosticsNode objects describing this node's children.
inherited
debugFillProperties(DiagnosticPropertiesBuilder properties) → void
Add additional properties associated with the node.
inherited
noSuchMethod(Invocation invocation) → dynamic
Invoked when a nonexistent method or property is accessed.
inherited
toDiagnosticsNode({String? name, DiagnosticsTreeStyle? style}) → DiagnosticsNode
Returns a debug representation of the object that is used by debugging tools and by DiagnosticsNode.toStringDeep.
inherited
toString({DiagnosticLevel minLevel = DiagnosticLevel.info}) → String
A string representation of this object.
inherited
toStringDeep({String prefixLineOne = '', String? prefixOtherLines, DiagnosticLevel minLevel = DiagnosticLevel.debug, int wrapWidth = 65}) → String
Returns a string representation of this node and its descendants.
inherited
toStringShallow({String joiner = ', ', DiagnosticLevel minLevel = DiagnosticLevel.debug}) → String
Returns a one-line detailed description of the object.
inherited
toStringShort() → String
A short, textual description of this widget.
inherited

Operators

operator ==(Object other) → bool
The equality operator.
inherited