Home > Blockchain >  Flutter Toggle List
Flutter Toggle List

Time:01-11

I don't know how to create toggle list like this in flutter.

Here is the image of I'm trying to create :

Toggle List in Alert Dialog

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;
    });
  },
)
  • Related