ExpandableSlider class

A slider that can be expanded to select values with more precision.

This widget is based on Flutter's Slider widget.

An expandable slider can have two status: "shrunk" and "expanded". An ExpandableSlider will always be a discrete Slider, i.e., a Slider with non-null Slider.divisions.

When shrunk, the default behavior will be that of a Flutter's Slider, that is, both the min and max values of the slider are visible and reachable by the slider thumb. Depending on the estimatedValueStep and shrunkWidth properties, a shrunk expandable slider can either have visible or invisible divisions: the divisions will be visible if the ExpandableSlider has enough room to present the divisions, and the divisions will be invisible otherwise.

An expanded ExpandableSlider will always have visible divisions, and the spacing between divisions will always be enough for the user to move the slider thumb between divisions easily. On the other hand, the min and max values of the slider might not be visible when the slider is expanded. If, while expanded, the slider thumb tries to exit the viewport, an animation will be triggered to move the viewport such that the slider thumb becomes visible again. This animation can be either:

  • A "snap center" animation, which is a scrolling animation that occurs when the slider is expanded and the value changes in such a way that would cause the slider thumb to travel as many pixels as 0.875 times the width of the viewport. This animation causes the slider thumb to return to the center of the viewport.
  • A "side scroll" animation, which is a scrolling animation that occurs when the slider is expanded and the value changes in such a way that would cause the slider thumb to exit the viewport, but not by travelling as many pixels as 0.875 times the width of the viewport. This animation does not cause the slider thumb to return to the center of the viewport.

Just like with Slider, the visual appearance can be finely tuned with SliderTheme and SliderThemeData.

See also:

  • Slider, which is a widget used to select from a range of values.
  • SliderTheme and SliderThemeData for information about controlling the visual appearance of the slider.
Inheritance

Constructors

ExpandableSlider({required double value, required void onChanged(double), void onChangeStart(double)?, void onChangeEnd(double)?, void onExpansionStart()?, void onShrinkageStart()?, double estimatedValueStep = 1, double? shrunkWidth, Color? inactiveColor, Color? activeColor, double min = 0, double max = 1, Duration expansionDuration = durations.mediumPresenting, Duration shrinkageDuration = durations.mediumDismissing, Duration snapCenterScrollDuration = durations.longPresenting, Duration sideScrollDuration = durations.shortPresenting, Curve expansionCurve = curves.exiting, Curve shrinkageCurve = curves.entering, Curve snapCenterScrollCurve = curves.base, Curve sideScrollCurve = curves.base, bool expandsOnLongPress = true, bool expandsOnScale = true, bool expandsOnDoubleTap = false, ScrollBehavior scrollBehavior = const ScrollBehavior(), ExpandableSliderController? controller, Key? key})
Creates a Material Design slider that can be expanded to select values with more precision.
const
ExpandableSlider.adaptive({required double value, required void onChanged(double), void onChangeStart(double)?, void onChangeEnd(double)?, void onExpansionStart()?, void onShrinkageStart()?, double estimatedValueStep = 1, double? shrunkWidth, Color? inactiveColor, Color? activeColor, double min = 0, double max = 1, Duration expansionDuration = durations.mediumPresenting, Duration shrinkageDuration = durations.mediumDismissing, Duration snapCenterScrollDuration = durations.longPresenting, Duration sideScrollDuration = durations.shortPresenting, Curve expansionCurve = curves.exiting, Curve shrinkageCurve = curves.entering, Curve snapCenterScrollCurve = curves.base, Curve sideScrollCurve = curves.base, bool expandsOnLongPress = true, bool expandsOnScale = true, bool expandsOnDoubleTap = false, ScrollBehavior scrollBehavior = const ScrollBehavior(), ExpandableSliderController? controller, Key? key})
Creates an ExpandableSlider that takes the appearance of a CupertinoSlider if the target platform is iOS, or that of a Material Design slider otherwise.
const

Properties

activeColor Color?
The color to use for the portion of the slider track that is active.
final
controller ExpandableSliderController?
An object that can be used to control the animations of the slider.
final
estimatedValueStep double
The estimated value change when the slider thumb jumps between divisions.
final
expandsOnDoubleTap bool
Whether to expand or shrink the slider when performing a double tap on it.
final
expandsOnLongPress bool
Whether to expand or shrink the slider when performing a long press on it.
final
expandsOnScale bool
Whether to expand or shrink the slider when performing a scale gesture on it.
final
expansionCurve Curve
The curve to use in the expansion animation.
final
expansionDuration Duration
The length of time the slider expansion animation animation should last.
final
hashCode int
The hash code for this object.
no setterinherited
inactiveColor Color?
The color for the inactive portion of the slider track.
final
key Key?
Controls how one widget replaces another widget in the tree.
finalinherited
max double
The maximum value the user can select.
final
min double
The minimum value the user can select.
final
onChanged → void Function(double)
Called during a drag when the user is selecting a new value.
final
onChangeEnd → (void Function(double)?)
Called when the user is done selecting a new value for the slider.
final
onChangeStart → (void Function(double)?)
Called when the user starts selecting a new value for the slider.
final
onExpansionStart → (void Function()?)
Called when the slider starts an expansion animation.
final
onShrinkageStart → (void Function()?)
Called when the slider starts a shrinkage animation.
final
runtimeType Type
A representation of the runtime type of the object.
no setterinherited
scrollBehavior ScrollBehavior
How the ScrollView that wraps the slider should behave.
final
shrinkageCurve Curve
The curve to use in the shrinkage animation.
final
shrinkageDuration Duration
The length of time the shrinkage animation should last.
final
shrunkWidth double?
If non-null, requires the slider to have exactly this width when shrunk.
final
sideScrollCurve Curve
The curve to use in the scrolling animation that occurs when the slider is expanded and the value changes in such a way that would cause the slider thumb to exit the viewport, but not by travelling as many pixels as 0.875 times the width of the viewport.
final
sideScrollDuration Duration
The duration of the scrolling animation that occurs when the slider is expanded and the value changes in such a way that would cause the slider thumb to exit the viewport, but not by travelling as many pixels as 0.875 times the width of the viewport.
final
snapCenterScrollCurve Curve
The curve to use in the scrolling animation that occurs when the slider is expanded and the value changes in such a way that would cause the slider to travel as many pixels as 0.875 times the width of the viewport.
final
snapCenterScrollDuration Duration
The duration of the scrolling animation that occurs when the slider is expanded and the value changes in such a way that would cause the slider thumb to travel as many pixels as 0.875 times the width of the viewport.
final
value double
The currently selected value for this slider.
final

Methods

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