GlassStepper class Panels and controls
A minus and a plus in one glass capsule, stepping a number between min
and max — iOS's UIStepper.
A press steps at once; held, the half repeats after kGlassStepperRepeatDelay every kGlassStepperRepeatInterval until the finger lifts or the value reaches a limit (autorepeat). At a limit the half that would pass it is disabled and its glyph dims, unless wraps.
The stepper holds no value of its own and shows none: onChanged is told the new one, the caller passes it back as value, and puts it in a label beside the stepper as iOS does.
Row(
children: <Widget>[
Expanded(child: Text('Copies: $copies')),
GlassStepper(
value: copies.toDouble(),
min: 1,
max: 10,
semanticLabel: 'Copies',
onChanged: (double v) => setState(() => copies = v.round()),
),
],
)
Note: one surface, whatever is held. A press, the autorepeat and a glyph dimming at a limit are drawn inside the glass, so none of them is a capture.
A screen reader hears one adjustable control — its semanticLabel and the value — and increases or decreases it by step. A keyboard steps a focused stepper with the arrow keys, and the focus ring is drawn around the capsule.
Under TextDirection.rtl it is mirrored: the minus is at the right, and the left arrow increases.
See also:
- GlassButtonGroup, several actions in one capsule, the same way.
- GlassSlider, a continuous value.
- Inheritance
-
- Object
- DiagnosticableTree
- Widget
- StatefulWidget
- GlassStepper
Constructors
-
GlassStepper({required double value, required ValueChanged<
double> ? onChanged, double min = 0, double max = 100, double step = 1, bool wraps = false, bool autorepeat = true, GlassFinish? finish, Color? pressedOverlay, String? semanticLabel, String semanticFormatterCallback(double value)?, FocusNode? focusNode, bool autofocus = false, Key? key}) -
A stepper showing
valuebetweenminandmaxin steps ofstep, reporting a change throughonChanged— null to disable it.const
Properties
- autofocus → bool
-
Whether the stepper takes the focus as soon as it is built.
final
- autorepeat → bool
-
Whether a held half keeps stepping. On by default, as
UIStepper.autorepeatis.final - finish → GlassFinish?
-
The optics. Null takes the theme's.
final
- focusNode → FocusNode?
-
The stepper's focus. Null makes one the stepper owns.
final
- hashCode → int
-
The hash code for this object.
no setterinherited
- key → Key?
-
Controls how one widget replaces another widget in the tree.
finalinherited
- max → double
-
The largest value. 100 by default, as
UIStepper's.final - min → double
-
The smallest value. 0 by default, as
UIStepper's.final -
onChanged
→ ValueChanged<
double> ? -
Called with the stepped value. Null disables the stepper: the glass
stays as it is and both glyphs dim to kGlassDisabledDarkLabel or
kGlassDisabledLightLabel, as a disabled GlassButton's label does.
final
- pressedOverlay → Color?
-
What is added over a held half. Null takes the finish's rim, as
GlassButton does.
final
- runtimeType → Type
-
A representation of the runtime type of the object.
no setterinherited
- semanticFormatterCallback → String Function(double value)?
-
How a screen reader says a value. Null says it as a number, without a
fraction when it has none.
final
- semanticLabel → String?
-
What a screen reader says the stepper is for.
final
- step → double
-
How far one press moves the value. 1 by default.
final
- value → double
-
The value, between min and max.
final
- wraps → bool
-
Whether stepping past max lands on min and past min on max. Off
by default, as
UIStepper.wrapsis; then the half that would pass a limit is disabled at it.final
Methods
-
createElement(
) → StatefulElement -
Creates a StatefulElement to manage this widget's location in the tree.
inherited
-
createState(
) → State< GlassStepper> -
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