custom_radio_group_list 1.1.1
custom_radio_group_list: ^1.1.1 copied to clipboard
Flutter package to create list of radio button, by providing a list of objects it can be a String list or list of Map..
1.0.0 #
- Initial release
1.1.0 #
- Able to set the color for radio button
- You can customize the label as per your needs
- Radio List can be generated using list of object.
Usage #
Example 1 #
This example shows using an object list
RadioGroup(
items: sampleList,
selectedItem: selectedItemNew,
onChanged: (value) {
selectedItemNew = value;
final snackBar = SnackBar(content: Text("$value"));
ScaffoldMessenger.of(context).showSnackBar(snackBar);
},
labelBuilder: (ctx, index) {
return Row(
children: [
Text(
'Id : ${sampleList[index].id}',
style: const TextStyle(color: Colors.red),
),
const SizedBox(
width: 10,
),
Text(
'City : ${sampleList[index].title}',
),
],
);
},
shrinkWrap: true,
disabled: false),
Example 2 #
This example shows use of String list to display radio group list.
RadioGroup(
items: stringList,
onChanged: (value) {
print('Value : $value');
selectedItem = value;
final snackBar = SnackBar(content: Text("$value"));
ScaffoldMessenger.of(context).showSnackBar(snackBar);
},
selectedItem: selectedItem,
disabled: true,
shrinkWrap: true,
labelBuilder: (ctx, index) {
return Text(stringList[index]);
},
),
Example 3 #
This example shows setting label and radio button color.
RadioGroup(
items: stringList,
onChanged: (value) {
print('Value : $value');
selectedItem = value;
final snackBar = SnackBar(content: Text("$value"));
ScaffoldMessenger.of(context).showSnackBar(snackBar);
},
selectedItem: selectedItem,
shrinkWrap: true,
fillColor: Colors.green,
labelBuilder: (ctx, index) {
return Text(
stringList[index],
style: TextStyle(
color: selectedItem == stringList[index]
? Colors.green
: Colors.black),
);
},
),