onChanged property

ValueChanged<T?>? onChanged
final

Called when the user selects this CupertinoRadio button.

The radio button passes value as a parameter to this callback. It does not actually change state until the parent widget rebuilds the radio button with a new groupValue.

If null, the radio button will be displayed as disabled.

The provided callback will not be invoked if this radio button is already selected.

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:

CupertinoRadio<SingingCharacter>(
  value: SingingCharacter.lafayette,
  groupValue: _character,
  onChanged: (SingingCharacter? newValue) {
    setState(() {
      _character = newValue;
    });
  },
)

Implementation

final ValueChanged<T?>? onChanged;