Skip to content

Commit e6d5bce

Browse files
Refactor user input radio buttons to use RadioGroup (#12679)
`groupValue` and `onChanged` parameter in `Radio` widget are deprecated after `v3.32.0-0.0.pre`. --------- Co-authored-by: Parker Lougheed <parlough@gmail.com>
1 parent 696a088 commit e6d5bce

File tree

1 file changed

+24
-36
lines changed

1 file changed

+24
-36
lines changed

src/content/get-started/fundamentals/user-input.md

Lines changed: 24 additions & 36 deletions
Original file line numberDiff line numberDiff line change
@@ -736,16 +736,16 @@ Widget build(BuildContext context) {
736736

737737
### Radio
738738

739-
A group of `Radio` buttons that allows the user to
739+
A `RadioGroup` contains `Radio` buttons that allow the user to
740740
select between mutually exclusive values.
741741
When the user selects a radio button in a group,
742742
the other radio buttons are unselected.
743743

744-
- A particular `Radio` button's `value` represent that button's value,
745-
- The selected value for a group of radio buttons is identified by
744+
- A particular `Radio` button's `value` represent that button's value.
745+
- The selected value for a `RadioGroup` is identified by
746746
the `groupValue` parameter.
747-
- `Radio` also has an `onChanged` callback that
748-
gets triggered when users click it, like `Switch` and `Checkbox`
747+
- `RadioGroup` has an `onChanged` callback that
748+
gets triggered when users click it, like `Switch` and `Checkbox`.
749749

750750
{% render "docs/code-and-image.md",
751751
image:"fwe/user-input/Radio.webp",
@@ -775,41 +775,29 @@ class _RadioExampleState extends State<RadioExample> {
775775
776776
@override
777777
Widget build(BuildContext context) {
778-
return Column(
779-
children: <Widget>[
780-
ListTile(
781-
title: const Text('Musician'),
782-
leading: Radio<Character>(
783-
value: Character.musician,
784-
groupValue: _character,
785-
onChanged: setCharacter,
778+
return RadioGroup(
779+
groupValue: _character,
780+
onChanged: setCharacter,
781+
child: Column(
782+
children: <Widget>[
783+
ListTile(
784+
title: const Text('Musician'),
785+
leading: Radio<Character>(value: Character.musician),
786786
),
787-
),
788-
ListTile(
789-
title: const Text('Chef'),
790-
leading: Radio<Character>(
791-
value: Character.chef,
792-
groupValue: _character,
793-
onChanged: setCharacter,
787+
ListTile(
788+
title: const Text('Chef'),
789+
leading: Radio<Character>(value: Character.chef),
794790
),
795-
),
796-
ListTile(
797-
title: const Text('Firefighter'),
798-
leading: Radio<Character>(
799-
value: Character.firefighter,
800-
groupValue: _character,
801-
onChanged: setCharacter,
791+
ListTile(
792+
title: const Text('Firefighter'),
793+
leading: Radio<Character>(value: Character.firefighter),
802794
),
803-
),
804-
ListTile(
805-
title: const Text('Artist'),
806-
leading: Radio<Character>(
807-
value: Character.artist,
808-
groupValue: _character,
809-
onChanged: setCharacter,
795+
ListTile(
796+
title: const Text('Artist'),
797+
leading: Radio<Character>(value: Character.artist),
810798
),
811-
),
812-
],
799+
],
800+
),
813801
);
814802
}
815803
}

0 commit comments

Comments
 (0)