CounterInput class

A numeric field flanked by a decrement and an increment button.

The value can be changed by tapping the buttons, holding them down to repeat, typing in the field, or pressing the arrow up / down keys while the field has focus. It is always kept inside [minValue, maxValue] and rounded to decimals fraction digits.

CounterInput(
  type: SemanticEnum.primary,
  minValue: 0,
  maxValue: 10,
  step: 0.5,
  onValueChanged: (oldValue, newValue) => debugPrint('$oldValue -> $newValue'),
)

Colours and metrics come from WeTheme; the individual colour parameters override them when set.

Platform: mobile (large tap targets).

Inheritance

Constructors

CounterInput({Key? key, CounterInputController? controller, FocusNode? focusNode, CounterInputChanged? onIncrement, CounterInputChanged? onDecrement, CounterInputChanged? onValueChanged, VoidCallback? onMin, VoidCallback? onMax, VoidCallback? onMinOverflow, VoidCallback? onMaxOverflow, SemanticEnum type = SemanticEnum.secondary, bool isOutlined = false, double? radius, SizeEnum size = SizeEnum.defaultSize, double minValue = 0, double maxValue = 100, double step = 1, int? decimals, double? height, Color? iconColor, Color? backgroundColor, Color? buttonColor, Color? textColor, bool enabled = true, bool readOnly = false, double? textFieldWidth})
Creates a counter input.
const

Properties

backgroundColor → Color?
Background of the text field.
final
buttonColor → Color?
Fill of the buttons, or their outline when isOutlined is true.
final
controller → CounterInputController?
Holds the value. When null an internal controller is created and disposed by this widget.
final
decimals → int?
Fraction digits the value is rounded to, and the number of decimals the field accepts.
final
enabled → bool
Whether the counter reacts to input at all.
final
focusNode → FocusNode?
Focus node of the text field. When null an internal one is used.
final
hashCode → int
The hash code for this object.
no setterinherited
height → double?
Overrides the height taken from the theme.
final
iconColor → Color?
Colour of the + and - glyphs.
final
isOutlined → bool
Whether to draw outlined buttons instead of filled ones.
final
key → Key?
Controls how one widget replaces another widget in the tree.
finalinherited
maxValue → double
Largest accepted value.
final
minValue → double
Smallest accepted value.
final
onDecrement → CounterInputChanged?
Called after the value shrank, with the previous and the new value.
final
onIncrement → CounterInputChanged?
Called after the value grew, with the previous and the new value.
final
onMax → VoidCallback?
Called when the value reaches maxValue.
final
onMaxOverflow → VoidCallback?
Called when incrementing is attempted while already at maxValue.
final
onMin → VoidCallback?
Called when the value reaches minValue.
final
onMinOverflow → VoidCallback?
Called when decrementing is attempted while already at minValue.
final
onValueChanged → CounterInputChanged?
Called after any change, with the previous and the new value.
final
radius → double?
Corner radius of the outer edges. Defaults to WeTheme.radius.base.
final
readOnly → bool
Whether typing is disabled while the buttons stay usable.
final
runtimeType → Type
A representation of the runtime type of the object.
no setterinherited
size → SizeEnum
Size step; picks the metrics from WeTheme.sizes.control.
final
step → double
Amount added or removed per tap. Must be greater than zero.
final
textColor → Color?
Colour of the typed value.
final
textFieldWidth → double?
Fixed width of the text field. When null it grows with its content.
final
type → SemanticEnum
Semantic colour of the buttons and of the field background.
final

Methods

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