Issue
I am trying to make multiple choice questions using RadioListTile
.
RadioListTile(
value: 1,
groupValue: 1,
onChanged: (val) {
print("Value");
print(val.runtimeType);
setSelectedRadio(val);
},
title: Text(snapshot.data!.data()["questions"]["question $i"]["option 1"]),
);
The error I am getting is
The argument type ‘Object?’ can’t be assigned to the parameter type ‘int’. ‘Object’ is from ‘dart:core’. setSelectedRadio(val);
I have checked the runtime type of value and it is returning int.
Solution
Pass int
as a generic argument to your RadioListTile
.
Replace this
RadioListTile(...)
with this
RadioListTile<int>(...)
Answered By – CopsOnRoad
Answer Checked By – Dawn Plyler (FlutterFixes Volunteer)