onChanged property Null safety

ValueChanged<T?>? onChanged
final

Called when the user selects this radio button.

The radio button passes value as a parameter to this callback. The radio button does not actually change state until the parent widget rebuilds the radio button with the 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:

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

Implementation

final ValueChanged<T?>? onChanged;