onChanged property

ValueChanged<RangeValues>? onChanged
final

Called when the user is selecting a new value for the slider by dragging.

The slider passes the new values to the callback but does not actually change state until the parent widget rebuilds the slider with the new values.

If null, the slider will be displayed as disabled.

The callback provided to onChanged should update the state of the parent StatefulWidget using the State.setState method, so that the parent gets rebuilt; for example:

link
RangeSlider(
  values: _rangeValues,
  min: 1.0,
  max: 10.0,
  onChanged: (RangeValues newValues) {
    setState(() {
      _rangeValues = newValues;
    });
  },
)

See also:

  • onChangeStart, which is called when the user starts changing the values.
  • onChangeEnd, which is called when the user stops changing the values.

Implementation

final ValueChanged<RangeValues>? onChanged;