RangeSlider constructor

  1. {Key? key,
  2. required RangeValues values,
  3. required ValueChanged<RangeValues>? onChanged,
  4. ValueChanged<RangeValues>? onChangeStart,
  5. ValueChanged<RangeValues>? onChangeEnd,
  6. double min = 0.0,
  7. double max = 1.0,
  8. int? divisions,
  9. RangeLabels? labels,
  10. Color? activeColor,
  11. Color? inactiveColor,
  12. MaterialStateProperty<Color?>? overlayColor,
  13. MaterialStateProperty<MouseCursor?>? mouseCursor,
  14. SemanticFormatterCallback? semanticFormatterCallback}

Creates a Material Design range slider.

The range slider widget itself does not maintain any state. Instead, when the state of the slider changes, the widget calls the onChanged callback. Most widgets that use a range slider will listen for the onChanged callback and rebuild the slider with new values to update the visual appearance of the slider. To know when the value starts to change, or when it is done changing, set the optional callbacks onChangeStart and/or onChangeEnd.

  • values, which determines currently selected values for this range slider.
  • onChanged, which is called while the user is selecting a new value for the range slider.
  • onChangeStart, which is called when the user starts to select a new value for the range slider.
  • onChangeEnd, which is called when the user is done selecting a new value for the range slider.

You can override some of the colors with the activeColor and inactiveColor properties, although more fine-grained control of the appearance is achieved using a SliderThemeData.

The values, min, max must not be null. The min must be less than or equal to the max. values.start must be less than or equal to values.end. values.start and values.end must be greater than or equal to the min and less than or equal to the max. The divisions must be null or greater than 0.


  required this.values,
  required this.onChanged,
  this.min = 0.0,
  this.max = 1.0,
}) : assert(min <= max),
     assert(values.start <= values.end),
     assert(values.start >= min && values.start <= max),
     assert(values.end >= min && values.end <= max),
     assert(divisions == null || divisions > 0);