Skip to main content

Slider

The Slider widget is an input control for picking a single value from a fixed range by dragging.
Use it to adjust continuous values such as volume, brightness, or a ratio.

Definition and role

The Slider widget lets you drag the thumb along a horizontal track to pick a value between min and max. Use divisions to split the track into equal steps so only discrete values can be chosen, and set the track, tick mark, and thumb colors along with the track thickness.

  • Category: Contents
  • Default range: min 0.0 to max 1.0
  • Default value: 0.0
  • Default size (SizedBox): 100 wide, 50 tall
  • Slider types: material (default) / adaptive

Features

FeatureDescription
Value selectionDrag the thumb along the track to pick a value between min and max.
Step divisionUse divisions to split the track into equal steps so only discrete values can be chosen. Leave it unset for continuous values.
Slider typeChoose between material (default) and adaptive, which adapts to the platform.
Color and track settingsSet the colors of the active and inactive track, the tick marks, the thumb, and the overlay, plus the track thickness.
Value change eventUse onChanged to hook up an action that runs whenever the value changes during a drag.

How to use

  1. Open the Contents category in the left widget palette.
  2. Drag and drop the Slider item onto the canvas.
  3. In the properties panel on the right, set the value range with min and max.
  4. If needed, split the range into steps with divisions, then adjust the track and thumb colors and trackHeight.
  5. Hook up the action — logic or a script — that should run on a value change to onChanged.

Properties

PropertyDescriptionDefaultValue / Type
sliderTypeSlider typematerialmaterial, adaptive
valueCurrently selected value0.0Number
minLowest value that can be selected0.0Number
maxHighest value that can be selected1.0Number
divisionsNumber of steps to split the track into (discrete values). Leave unset for continuous valuesNot setInteger (1 or greater)
trackHeightTrack thicknessNot setNumber
activeTrackColorTrack color left of the thumb — the selected rangeNot setColor
inactiveTrackColorTrack color right of the thumb — the unselected rangeNot setColor
activeTickMarkColorTick mark color in the selected rangeNot setColor
inactiveTickMarkColorTick mark color in the unselected rangeNot setColor
thumbColorThumb colorNot setColor
overlayColorColor of the overlay that appears when you press the thumbNot setColor
focusNodeFocus node used for focus controlNot setFocus node
autofocusWhether to take focus automatically when the widget appearsfalsetrue / false

Notes and tips

tip

Set divisions and the value snaps to equal steps instead of moving continuously. Leave it unset and you can pick any value between min and max.

note

activeTrackColor applies to the selected range left of the thumb, and inactiveTrackColor applies to the unselected range on the right.

Learn more

tip

For the full set of Widget Controls (Property, Method, and Event) that let you drive this widget from a script, see Slider Widget Control.