NumberBox<T extends num> class

A fluent design input form for numbers.

A NumberBox lets the user enter a number. If the user input a wrong value (a NaN value), the previous valid value is used.

The value can be changed in several ways:

Modes: SpinButtonPlacementMode.inline : Show two icons as a suffix of the text field. With for increment the value and one for decrement the value. SpinButtonPlacementMode.compact : Without the focus, it's appears like a normal text field. But when the widget has the focus, an overlay is visible with a button for increment the value and another for decrement the value. SpinButtonPlacementMode.none : Don't show any additional button on the text field.

If the parameter clearButton is enabled, an additional icon is shown for clear the value when the widget has the focus.

See also:

Inheritance
Available Extensions

Constructors

NumberBox({Key? key, required T? value, required ValueChanged<T?>? onChanged, ValueChanged<String>? onTextChange, FocusNode? focusNode, SpinButtonPlacementMode mode = SpinButtonPlacementMode.compact, bool clearButton = true, num smallChange = 1, num largeChange = 10, int precision = 2, num? min, num? max, bool allowExpressions = false, Widget? leadingIcon, bool autofocus = false, List<TextInputFormatter>? inputFormatters, String? placeholder, TextStyle? placeholderStyle, double cursorWidth = 1.5, Radius cursorRadius = const Radius.circular(2.0), double? cursorHeight, Color? cursorColor, bool? showCursor, Color? highlightColor, Color? unfocusedColor, TextStyle? style, TextAlign? textAlign, TextInputType? keyboardType = TextInputType.number, DragStartBehavior dragStartBehavior = DragStartBehavior.start, bool enableInteractiveSelection = true, Brightness? keyboardAppearance, ScrollController? scrollController, EdgeInsets scrollPadding = const EdgeInsets.all(20.0), ScrollPhysics? scrollPhysics, TextSelectionControls? selectionControls, BoxHeightStyle selectionHeightStyle = ui.BoxHeightStyle.tight, BoxWidthStyle selectionWidthStyle = ui.BoxWidthStyle.tight, TextDirection? textDirection})
Creates a number box.
const

Properties

allowExpressions bool
When true, if something else than a number is specified, the content of the text box is interpreted as a math expression when the focus is lost.
final
autofocus bool
Whether this text field should focus itself if nothing else is already focused.
final
clearButton bool
When false, it disable the suffix button with a cross for remove the content of the number box.
final
cursorColor Color?
The color of the cursor.
final
cursorHeight double?
How tall the cursor will be.
final
cursorRadius Radius
How rounded the corners of the cursor should be.
final
cursorWidth double
How thick the cursor will be.
final
dragStartBehavior DragStartBehavior
Determines the way that drag start behavior is handled.
final
enableInteractiveSelection bool
Whether to enable user interface affordances for changing the text selection.
final
focusNode FocusNode?
An optional focus node to use as the focus node for this widget.
final
hashCode int
The hash code for this object.
no setterinherited
highlightColor Color?
The highlight color of the text box.
final
inputFormatters List<TextInputFormatter>?
Optional input validation and formatting overrides.
final
key Key?
Controls how one widget replaces another widget in the tree.
finalinherited
keyboardAppearance Brightness?
The appearance of the keyboard.
final
keyboardType TextInputType?
The type of keyboard to use for editing the text.
final
largeChange num
The value that is incremented when the user click on the shortcut LogicalKeyboardKey.pageUp and decremented when the user lick on the shortcut LogicalKeyboardKey.pageDown.
final
leadingIcon Widget?
A widget displayed at the start of the text box
final
max num?
The maximum value allowed. If the user input a value greater than max, the value is replaced by max. If max is null, there is no upper limit.
final
min num?
The minimum value allowed. If the user input a value below than min, the value is replaced by min. If min is null, there is no lowest limit.
final
mode SpinButtonPlacementMode
Display modes for the Number Box.
final
onChanged ValueChanged<T?>?
Called when the value of the number box change. The callback is fired only if the user click on a button or the focus is lost.
final
onTextChange ValueChanged<String>?
Called when the text of the number box change.
final
placeholder String?
The text shown when the text box is empty
final
placeholderStyle TextStyle?
The style of placeholder
final
precision int
The precision indicates the number of digits that's accepted for double value.
final
runtimeType Type
A representation of the runtime type of the object.
no setterinherited
scrollController ScrollController?
The ScrollController to use when vertically scrolling the input.
final
scrollPadding EdgeInsets
Configures padding to edges surrounding a Scrollable when the Textfield scrolls into view.
final
scrollPhysics ScrollPhysics?
The ScrollPhysics to use when vertically scrolling the input.
final
selectionControls TextSelectionControls?
Optional delegate for building the text selection handles.
final
selectionHeightStyle BoxHeightStyle
Controls how tall the selection highlight boxes are computed to be.
final
selectionWidthStyle BoxWidthStyle
Controls how wide the selection highlight boxes are computed to be.
final
showCursor bool?
Whether to show cursor.
final
smallChange num
The value that is incremented or decremented when the user click on the buttons or when he scroll on the number box.
final
style TextStyle?
The style to use for the text being edited.
final
textAlign TextAlign?
How the text should be aligned horizontally.
final
textDirection TextDirection?
The directionality of the text.
final
unfocusedColor Color?
The unfocused color of the highlight border.
final
value → T?
The value of the number box. When this value is null, the number box field is empty.
final

Methods

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