I don't know how to create toggle list like this in flutter.
Here is the image of I'm trying to create :
CodePudding user response:
You can use RadioListTile()
enum Fruit { apple, banana }
Fruit? _fruit = Fruit.apple;
RadioListTile<Fruit>(
title: const Text('Apple'),
value: Fruit.apple,
groupValue: _fruit,
onChanged: (Fruit? value) {
setState(() {
_fruit = value;
});
},
)
RadioListTile<Fruit>(
title: const Text('Banana'),
value: Fruit.banana,
groupValue: _fruit,
onChanged: (Fruit? value) {
setState(() {
_fruit = value;
});
},
)