onChangeEnd property

ValueChanged<double>? onChangeEnd
final

Called when the user is done 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 know when the user has completed selecting a new value by ending a drag or a click.

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

See also:

  • onChangeStart for a callback that is called when a value change begins.

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();
///     });
///   },
///   onChangeEnd: (double newValue) {
///     print('Ended change on $newValue');
///   },
/// )
/// ```
///
/// </callout-box>
///
/// See also:
///
///  * [onChangeStart] for a callback that is called when a value change
///    begins.
final ValueChanged<double>? onChangeEnd;