Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

RadioListTile onchange value is object? type

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.

like image 471
doc Avatar asked Oct 25 '25 19:10

doc


1 Answers

Pass int as a generic argument to your RadioListTile.

Replace this

RadioListTile(...)

with this

RadioListTile<int>(...)
like image 171
CopsOnRoad Avatar answered Oct 28 '25 22:10

CopsOnRoad



Donate For Us

If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!