I want to set the index of RadioListTile inside the listview.builder but i can't do that how to do it which I want to get the value of this index here is my code
int _value=0;
List valueList=[];
ListView.Builder(itemBuilder:(context,index){
return Row(
mainAxisAlignment: MainAxisAlignment.center,
children: [
Expanded(
child: RadioListTile<int>(
dense: true,
activeColor: colorsCheck(),
contentPadding:
EdgeInsets.symmetric(horizontal: 1.0),
title: Text(
'Present',
style: TextStyle(
color: Colors.white, fontSize: 12.0),
),
value: 1,
groupValue: _value,
onChanged: (value) {
setState(() {
_value=value;
valueList.add(value);
print('radio button value present ${valueList.toList().toString()}');
});
},
),
),
Expanded(
child: RadioListTile<int>(
contentPadding:
EdgeInsets.symmetric(horizontal: 1.0),
dense: true,
activeColor: colorsCheck(),
title: Text(
'Absent',
style: TextStyle(
color: Colors.white, fontSize: 12.0),
),
value: 2,
groupValue: _value,
onChanged: (value) {
setState(() {
_value=value;
valueList.add(value);
print('radio button value absent ${valueList.toList().toString()}');
});
},
),
),
Expanded(
child: RadioListTile<int>(
dense: true,
activeColor: colorsCheck(),
contentPadding:
EdgeInsets.symmetric(horizontal: 1.0),
title: Text(
'Leave',
style: TextStyle(
color: Colors.white, fontSize: 12.0),
),
value: 3,
groupValue:_value,
onChanged: (value) {
setState(() {
_value=value;
valueList.add(value);
print('radio button value leave ${valueList.toList().toString()}');
});
},
),
),
],
),
}
Row is inside card where 3 radio button is set (present, absent, leave) but when I click it changes all item builder value. I just want to change the value of that radio inside the card which it clicks. other not. here is an image ...
look inside the picture where the leave radio button is set only top value but it set all.
See Question&Answers more detail:
os