GlassSlider class Panels and controls
A slider whose knob becomes a clear glass drop while it is held.
Every frame of a drag changes the fill under the drop, so every frame of a drag is a capture — see the file comment. The knob moving is not.
The value runs from 0 to 1 and is the caller's: onChanged is told each
new one while a finger is down — a tap places the knob, a drag carries it —
and the caller passes it back as value. onChangeStart and
onChangeEnd bracket the gesture. A screen reader's increase and decrease
move it by semanticStep — or by one division, when divisions snaps the
value to divisions + 1 stops, as Material's Slider does.
The arrow keys step a focused slider by the same unit, and the focus ring is drawn around its knob. Under TextDirection.rtl it is mirrored: 0 is at the right and the fill grows leftward, and the left arrow increases.
GlassSlider(
value: volume,
semanticLabel: 'Volume',
onChanged: (double v) => setState(() => volume = v),
onChangeEnd: (double v) => player.setVolume(v),
)
Note: the fill ends under the drop and follows it, so every frame of a drag is a real change under glass and is retaken. A screen of sliders at rest costs nothing; a held one costs a capture a frame.
See also:
- GlassSwitch, the same drop on a boolean.
- SliderGeometry.fillEnd, where the fill ends for a value.
- GlassDropMotion, how the held drop stretches and squashes.
- Slider on the site.
- Inheritance
-
- Object
- DiagnosticableTree
- Widget
- StatefulWidget
- GlassSlider
Constructors
-
GlassSlider({required double value, required ValueChanged<
double> ? onChanged, ValueChanged<double> ? onChangeStart, ValueChanged<double> ? onChangeEnd, Color? activeColor, Color? trackColor, double dropScale = kGlassDropScale, double dropWiden = 0, GlassDropMotion? dropMotion, String? semanticLabel, double semanticStep = 0.1, int? divisions, FocusNode? focusNode, bool autofocus = false, Key? key}) -
A slider showing
value, reporting a change throughonChanged— null to disable it.const
Properties
- activeColor → Color?
-
The fill from 0 to value. Null for iOS's
systemBluein the appearance of the label around the slider: on glass, the glass's.final - autofocus → bool
-
Whether the slider takes the focus as soon as it is built.
final
- divisions → int?
-
How many equal steps the value snaps to between 0 and 1, or null for a
continuous slider. A drag, a tap, a key and a screen reader all land on
a stop, and onChanged is told only when the stop changes.
final
- dropMotion → GlassDropMotion?
-
See GlassSwitch.dropMotion.
final
- dropScale → double
-
How much larger the held drop is than the resting knob. See
kGlassDropScale; macOS's own slider is 1.4.
final
- dropWiden → double
-
See GlassSwitch.dropWiden. 0, because iOS's slider drop does not
minify.
final
- focusNode → FocusNode?
-
The slider's focus. Null makes one the slider 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
-
onChanged
→ ValueChanged<
double> ? -
Null disables the slider; it is then drawn at kGlassDisabledOpacity.
final
-
onChangeEnd
→ ValueChanged<
double> ? -
Called once at the end of the gesture — the finger lifted or taken away,
the slider disabled under it, a step landed — with the last value
onChanged was told, as Material's
Sliderdoes.final -
onChangeStart
→ ValueChanged<
double> ? -
Called with the value before the gesture, as a finger comes down or a
screen reader or a key steps the value — once, before any onChanged of
that gesture.
final
- runtimeType → Type
-
A representation of the runtime type of the object.
no setterinherited
- semanticLabel → String?
-
What a screen reader says the slider is for. Null leaves it to a
MergeSemanticsaround the slider and its row's label.final - semanticStep → double
-
How far a screen reader's increase or decrease — and an arrow key —
moves the value: a tenth, as Flutter's own continuous slider does.
Ignored when divisions is set: the step is then one division.
final
- trackColor → Color?
-
The track behind the fill. Null for iOS's
secondarySystemFillin that appearance.final - value → double
-
Between 0 and 1.
final
Methods
-
createElement(
) → StatefulElement -
Creates a StatefulElement to manage this widget's location in the tree.
inherited
-
createState(
) → State< GlassSlider> -
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