RangeSlider constructor

RangeSlider(
  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 min must be less than or equal to the max.

The RangeValues.start attribute of the values parameter must be less than or equal to its RangeValues.end attribute. The RangeValues.start and RangeValues.end attributes of the values parameter must be greater than or equal to the min parameter and less than or equal to the max parameter.

The divisions parameter must be null or greater than zero.

Implementation

RangeSlider({
  super.key,
  required this.values,
  required this.onChanged,
  this.onChangeStart,
  this.onChangeEnd,
  this.min = 0.0,
  this.max = 1.0,
  this.divisions,
  this.labels,
  this.activeColor,
  this.inactiveColor,
  this.overlayColor,
  this.mouseCursor,
  this.semanticFormatterCallback,
}) : 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);