onChanged property

ValueChanged<bool?>? onChanged
final

Called when the value of the checkbox should change.

The checkbox passes the new value to the callback but does not actually change state until the parent widget rebuilds the checkbox tile with the new value.

If null, the checkbox 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
CheckboxListTile(
  value: _throwShotAway,
  onChanged: (bool? newValue) {
    setState(() {
      _throwShotAway = newValue;
    });
  },
  title: const Text('Throw away your shot'),
)

Implementation

final ValueChanged<bool?>? onChanged;