Closed muslimmuda15 closed 4 months ago
The code in examples 2 and 3 has some small syntax errors. These could be causing the issue.
Example 2:
values
list is not constant, since it gets its values from a non-constant list; so, the list should not start with the const
keyword.vehicle[1]
and vehicle[2]
.vehicle[2]
has an index of 12
instead of 2
.Example 3:
After fixing these syntax errors, each version of the code works for me.
Helpful tip: After updating the code in these radio groups, do a hot restart to make sure all of the state data is up to date.
Recommended code:
I recommend using the labelBuilder
property if all of your widgets will be the same.
// Note: This RadioGroupController is specifically designated with the <String> type tag.
// Use the type that matches the data in your list
final RadioGroupController<String> radioController = RadioGroupController();
final List<String> vehicle = const ["Car", "Ship", "Bike"];
RadioGroup(
controller: radioController,
indexOfDefault: vehicleIndex,
orientation: RadioGroupOrientation.vertical,
values: vehicle,
labelBuilder: (value) => Padding(
padding: const EdgeInsets.only(left: 4),
child: Text(value),
),
onChanged: (value) {},
),
I'm going to go ahead and close this issue because I believe it is answered; however, if you have any more questions, feel free to re-open it.
yes, you can close this, thank you.
This code is working well:
but when the values change using variable, all radio button suddendly not checked all after selecting:
And I when I using
map
, it still doesn't workHow to solve this?