Slider
A Slider allows users to select a numeric value or range by dragging a thumb along a track. It provides an efficient way to adjust values within a defined range, such as price, volume, or time.
Use this component when users need to make quick, approximate selections from a continuous or discrete range.
Common alternative names:
Range Input, Range Slider
Variants
Section titled “Variants”Single Value Slider
Section titled “Single Value Slider”A slider for selecting a single value from a range.
DragSlider( value: _value, onChanged: (value) => setState(() => _value = value),)Range Slider
Section titled “Range Slider”A slider for selecting a range of values with two thumbs.
DragRangeSlider( values: _dragRangeSlider, onChanged: (value) => setState(() => _dragRangeSlider = value),)Properties
Section titled “Properties”DragSlider
Section titled “DragSlider”| Property | Type | Description |
|---|---|---|
value | double | The current value of the slider. |
onChanged | void Function(double)? | Callback function when the slider value changes. |
onChangeStart | void Function(double)? | Callback function when the user starts changing the slider value. |
onChangeEnd | void Function(double)? | Callback function when the user finishes changing the slider value. |
min | double | The minimum value of the slider range. |
max | double | The maximum value of the slider range. |
thumbRadius | double | The radius of the slider thumb in logical pixels. |
trackHeight | double | The height of the slider track in logical pixels. |
divisions | int? | The number of discrete divisions on the slider track. |
activeColor | Color? | The color of the active portion of the slider track. |
inactiveColor | Color? | The color of the inactive portion of the slider track. |
secondaryActiveColor | Color? | The color of the secondary active track (used for additional visual feedback). |
thumbColor | Color? | The color of the slider thumb. |
overlayColor | WidgetStateProperty<Color?>? | The color of the overlay that appears when the slider is pressed. |
mouseCursor | MouseCursor? | The cursor to display when hovering over the slider. |
focusNode | FocusNode? | The focus node for keyboard navigation. |
autofocus | bool | Whether the slider should automatically gain focus when the widget is built. |
allowedInteraction | SliderInteraction? | The types of interaction allowed for the slider. |
padding | EdgeInsetsGeometry? | The padding around the slider. |
DragRangeSlider
Section titled “DragRangeSlider”| Property | Type | Description |
|---|---|---|
values | RangeValues | The current values of the range slider (start and end values). |
onChanged | void Function(RangeValues)? | Callback function when the slider range values change. |
onChangeStart | void Function(RangeValues)? | Callback function when the user starts changing the slider range values. |
onChangeEnd | void Function(RangeValues)? | Callback function when the user finishes changing the slider range values. |
min | double | The minimum value of the slider range. Defaults to 0. |
max | double | The maximum value of the slider range. Defaults to 100. |
thumbRadius | double | The radius of the slider thumbs in logical pixels. Defaults to 8. |
trackHeight | double | The height of the slider track in logical pixels. Defaults to 4. |
divisions | int? | The number of discrete divisions on the slider track. |
activeColor | Color? | The color of the active portion of the slider track (between the two thumbs). |
inactiveColor | Color? | The color of the inactive portions of the slider track. |
overlayColor | WidgetStateProperty<Color?>? | The color of the overlay that appears when the slider thumbs are pressed. |