I want to display 3 radio button in my App UI. but it doesnt work. heres the code I tried.

CodePudding user response:
you can either use this plugin:- https://pub.dev/packages/group_radio_button
or set a int as a group value:
int groupValue = -1;
set the group value of RadioListButton in ascending order.
ListTile(
title: Text("Male"),
leading: Radio(
value: "male",
groupValue: 0,
onChanged: (value){
setState(() {
groupValue =value;
});
}),
),
ListTile(
title: Text("Male"),
leading: Radio(
value: "female",
groupValue: 1,
onChanged: (value){
setState(() {
groupValue =value;
});
}),
),
ListTile(
title: Text("Other"),
leading: Radio(
value: "other",
groupValue: 2,
onChanged: (value){
setState(() {
groupValue =value;
});
}),
)
],
and use RadioList button instead of Radio.

