onChanged property

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.

onChanged 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; for example:

Radio<String>(
  value: 'Option A',
  groupValue: _groupValue,
  onChanged: (String newValue) {
    setState(() {
      _groupValue = newValue;
    });
  },
)

Implementation

final ValueChanged<T> onChanged;