NumberInput
A numeric variant of TextInput — accepts digits, an optional
leading -, and (when allowDecimal is true) one .. Anything
else is silently rejected so the field’s text always parses, and
onChanged fires with the parsed num (or null for empty /
in-progress edits like "-" or "1.").
See also: Stepper for arrow-key increments.
Learn more: Forms & validation
Import: package:fleury/fleury.dart, or package:fleury/fleury_core.dart in browser code.
NumberInput( initialValue: 42, min: 0, max: 100, // null while the field is empty or mid-edit ("-", "1."). onChanged: (value) => setState(() => count = value),)Details
Section titled “Details”Wraps TextInput under the hood — its placeholder, focus, cursor, and
Enter-to-submit behavior carry over. There is no Escape callback, so
Escape passes on to enclosing widgets. Use this when you’d otherwise pair
a TextInput with int.tryParse everywhere.
Constructors
Section titled “Constructors”NumberInput()
Section titled “NumberInput()”| Parameter | Type | Default | Description |
|---|---|---|---|
initialValue: | num? | — | Initial parsed value to seed the field with. null starts empty. More |
controller: | TextEditingController? | — | Optional text controller for embedding this field in a larger form. |
onChanged: | void Function(num? value)? | — | Called with the parsed value after user or semantic edits. Programmatic controller writes notify controller listeners instead. null is passed when the field is empty or holds an in-progress token like "-" or "1." that doesn’t yet parse to a num. |
onSubmit: | void Function(num? value)? | — | Called with the final parsed value when the user presses Enter. Same null semantics as onChanged. |
min: | num? | — | Clamps the parsed value (after the user finishes editing) to this lower bound. Per-keystroke values below the bound are still accepted while the user is typing — the clamp applies on submit. Set to enforce a non-negative budget, percentage, etc. More |
max: | num? | — | Upper-bound mirror of min. Must be an int when allowDecimal is false. |
allowNegative: | bool | true | When false, the field rejects - entirely. |
allowDecimal: | bool | false | When true, the field accepts one . for decimal entry. When false, only integer digits are accepted. |
placeholder: | String | '' | Forwarded to the inner TextInput verbatim. |
placeholderStyle: | CellStyle | const CellStyle(dim: true) | Style used for placeholder. |
style: | CellStyle | CellStyle.none | Entered-text base styling, plus optional hover, focus, disabled, and invalid state entries from CellStyle.interactive. |
cursorStyle: | CellStyle | const CellStyle(inverse: true) | Style applied to the cursor cell. |
semanticLabel: | String? | — | Label exposed through the semantic app graph. More |
focusNode: | FocusNode? | — | Focus node used by the underlying text input. |
autofocus: | bool | false | Whether the field should request focus when mounted. |
enabled: | bool | true | Whether the field accepts focus and user input. |
readOnly: | bool | false | Whether the field can receive focus but not edit text. |
initialValue: Used once when the internal controller is created; rebuilds do not reset edits. Supply either this seed orcontroller. This must be anintwhenallowDecimalis false.min: Must be anintwhenallowDecimalis false.semanticLabel: When omitted,placeholderstill labels the underlying text field.
Source
Section titled “Source”NumberInput is defined in packages/fleury/lib/src/catalog/number_input.dart.
Category: Inputs & controls · All widgets