onChangeStart property

ValueChanged<double>? onChangeStart
final

Called when the user starts selecting a new value for the slider.

This callback shouldn't be used to update the slider value (use onChanged for that), but rather to be notified when the user has started selecting a new value by starting a drag or with a tap.

The value passed will be the last value that the slider had before the change began.

Slider(
  value: _duelCommandment.toDouble(),
  min: 1.0,
  max: 10.0,
  divisions: 10,
  label: '$_duelCommandment',
  onChanged: (double newValue) {
    setState(() {
      _duelCommandment = newValue.round();
    });
  },
  onChangeStart: (double startValue) {
    print('Started change at $startValue');
  },
)

See also:

  • onChangeEnd for a callback that is called when the value change is complete.

Implementation

// TODO(framework): Add unit tests to this code snippet.
// https://github.com/flutter/flutter/issues/188530
///
/// ```dart
/// Slider(
///   value: _duelCommandment.toDouble(),
///   min: 1.0,
///   max: 10.0,
///   divisions: 10,
///   label: '$_duelCommandment',
///   onChanged: (double newValue) {
///     setState(() {
///       _duelCommandment = newValue.round();
///     });
///   },
///   onChangeStart: (double startValue) {
///     print('Started change at $startValue');
///   },
/// )
/// ```
///
/// </callout-box>
///
/// See also:
///
///  * [onChangeEnd] for a callback that is called when the value change is
///    complete.
final ValueChanged<double>? onChangeStart;