DesignNumberField class

A number typed or stepped: value the number, null when empty; onChanged gets it as it is taken (Enter, the focus leaving, a step), not on each key typed.

The text is the reader's (DesignLocalizations.formatDecimal: German's 1.234,5; Arabic's in Arabic-Indic digits, U+0660 to U+0669, grouped by U+066C with U+066B for the point) and reads back in their digits or ASCII. A number typed is clamped to min and max and rounded to fractionDigits; one that does not read puts the last value back.

A step goes to the next multiple of step counted from min (or 0) that way, exactly in decimals (0.1 then 0.2 then 0.3), and takes typed text first. Keys in the field: Up and Down a step, Page Up and Page Down pageStep; Home and End stay the caret's. The two buttons step once on a press and repeat while held; they are no tab stops and no screen reader nodes: the field's own node steps, with the next and previous values.

That node takes its value from the input's, merged into it. An input that says itself whether it is enabled (Material's TextField) does not merge: Flutter keeps apart two nodes that both say so, and the field's node is left with next and previous values but no value, which Flutter 3.47 asserts against. Give the value on the field's node, round the input in fieldBuilder: ListenableBuilder(listenable: field.controller, builder: (context, child) => Semantics(value: field.controller.text, child: child), child: TextField(...)) (the input then stands in a node of its own under it).

DesignNumberField(value: 2, onChanged: (value) {}, min: 0, fieldBuilder: (context, field) => EditableText(controller: field.controller, focusNode: field.focusNode, keyboardType: field.keyboardType, inputFormatters: field.inputFormatters, onEditingComplete: field.onEditingComplete, style: const TextStyle(), cursorColor: const Color(0xFF000000), backgroundCursorColor: const Color(0xFF808080)), buttonBuilder: (context, button) => Text(button.isIncrement ? '+' : '−'))
Inheritance

Constructors

DesignNumberField({Key? key, required double? value, required ValueChanged<double?>? onChanged, required DesignNumberFieldBuilder fieldBuilder, required DesignNumberFieldButtonBuilder buttonBuilder, DesignNumberFieldLayoutBuilder? layoutBuilder, double? min, double? max, double step = 1, double? pageStep, int? fractionDigits, TextEditingController? controller, FocusNode? focusNode, bool autofocus = false, String? semanticLabel, String semanticFormatterCallback(double value)?, Duration repeatDelay = const Duration(milliseconds: 400), Duration repeatInterval = const Duration(milliseconds: 80)})
A number field showing value.
const

Properties

autofocus → bool
Whether the field takes focus when it first shows.
final
buttonBuilder → DesignNumberFieldButtonBuilder
Paints a step button.
final
controller → TextEditingController?
The text the field edits; null: the field's own.
final
fieldBuilder → DesignNumberFieldBuilder
Paints the text input. One that says itself whether it is enabled (Material's TextField) gives the field's node its value round it (see DesignNumberField).
final
focusNode → FocusNode?
The field's focus; null: the field's own.
final
fractionDigits → int?
The decimals a typed number keeps; null: as many as step and min have. The text shows as many as the number has, up to these.
final
hashCode → int
The hash code for this object.
no setterinherited
key → Key?
Controls how one widget replaces another widget in the tree.
finalinherited
layoutBuilder → DesignNumberFieldLayoutBuilder?
Lays out the input and the buttons; null: a row of decrement, field, increment, in reading order (mirrored right to left).
final
max → double?
The greatest value; null, none.
final
min → double?
The least value; null, none.
final
onChanged → ValueChanged<double?>?
Called with the number as it is taken, or null when the field is cleared.
final
pageStep → double?
What Page Up and Page Down move by; null: ten steps.
final
repeatDelay → Duration
How long a button is held before it repeats.
final
repeatInterval → Duration
How often a held button steps once it repeats.
final
runtimeType → Type
A representation of the runtime type of the object.
no setterinherited
semanticFormatterCallback → String Function(double value)?
How a screen reader says the next and previous values ("3 guests"); null: the number in the reader's digits.
final
semanticLabel → String?
What a screen reader calls the field ("Quantity"); null: the look's label, if it gives one.
final
step → double
What a step moves by, to the next multiple counted from min (or 0). Defaults to 1: whole numbers, with no decimal key.
final
value → double?
The number shown; null, empty.
final

Methods

createElement() → StatefulElement
Creates a StatefulElement to manage this widget's location in the tree.
inherited
createState() → State<DesignNumberField>
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.
override
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