im using flutter 2.8.1, so the idea is im using Radio widget with stateful then when i try to change the groupValue of the Radio widget with the new value / onChanged:(value) it tells this
the value has red underline
Object? value
A value of type 'Object?' can't be assigned to a variable of type 'int'.
Try changing the type of the variable, or casting the right-hand type to 'int'.
code
int radioValue = 0;
Radio(
materialTapTargetSize: MaterialTapTargetSize.shrinkWrap,
value: index,
groupValue: radioValue,
onChanged: (value) {
print(e['value']);
setState(() {
radioValue = value;
});
},
),
CodePudding user response:
change Radio to Radio<int>
and the value to value!
CodePudding user response:
Radio<int>(
value: radioValue,
groupValue: 2,
onChanged: (v) {
setState(() {
radioValue = v!;
});
},
)