Slider.adaptive constructor

const Slider.adaptive({
  1. Key? key,
  2. required double value,
  3. double? secondaryTrackValue,
  4. required ValueChanged<double>? onChanged,
  5. ValueChanged<double>? onChangeStart,
  6. ValueChanged<double>? onChangeEnd,
  7. double min = 0.0,
  8. double max = 1.0,
  9. int? divisions,
  10. String? label,
  11. MouseCursor? mouseCursor,
  12. Color? activeColor,
  13. Color? inactiveColor,
  14. Color? secondaryActiveColor,
  15. Color? thumbColor,
  16. MaterialStateProperty<Color?>? overlayColor,
  17. SemanticFormatterCallback? semanticFormatterCallback,
  18. FocusNode? focusNode,
  19. bool autofocus = false,
  20. SliderInteraction? allowedInteraction,
})

Creates an adaptive Slider based on the target platform, following Material design's Cross-platform guidelines.

Creates a CupertinoSlider if the target platform is iOS or macOS, creates a Material Design slider otherwise.

If a CupertinoSlider is created, the following parameters are ignored: secondaryTrackValue, label, inactiveColor, secondaryActiveColor, semanticFormatterCallback.

The target platform is based on the current Theme: ThemeData.platform.

Implementation

const Slider.adaptive({
  super.key,
  required this.value,
  this.secondaryTrackValue,
  required this.onChanged,
  this.onChangeStart,
  this.onChangeEnd,
  this.min = 0.0,
  this.max = 1.0,
  this.divisions,
  this.label,
  this.mouseCursor,
  this.activeColor,
  this.inactiveColor,
  this.secondaryActiveColor,
  this.thumbColor,
  this.overlayColor,
  this.semanticFormatterCallback,
  this.focusNode,
  this.autofocus = false,
  this.allowedInteraction,
}) : _sliderType = _SliderType.adaptive,
     assert(min <= max),
     assert(value >= min && value <= max,
       'Value $value is not between minimum $min and maximum $max'),
     assert(secondaryTrackValue == null || (secondaryTrackValue >= min && secondaryTrackValue <= max),
       'SecondaryValue $secondaryTrackValue is not between $min and $max'),
     assert(divisions == null || divisions > 0);