onChanged property
final
Called when the user selects a new value for the slider.
The slider passes the new value to the callback but does not actually change state until the parent widget rebuilds the slider with the new value.
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:
CupertinoSlider(
value: _cupertinoSliderValue.toDouble(),
min: 1.0,
max: 10.0,
divisions: 10,
onChanged: (double newValue) {
setState(() {
_cupertinoSliderValue = newValue.round();
});
},
)
See also:
- onChangeStart for a callback that is called when the user starts changing the value.
- onChangeEnd for a callback that is called when the user stops changing the value.
Implementation
final ValueChanged<double>? onChanged;