Skip to content

Instantly share code, notes, and snippets.

@liemvo
Created August 25, 2020 10:11
Show Gist options
  • Save liemvo/492a0914fcd054a4f8ca91cb1754267e to your computer and use it in GitHub Desktop.
Save liemvo/492a0914fcd054a4f8ca91cb1754267e to your computer and use it in GitHub Desktop.
_showMultiChoiceDialog(BuildContext context) => showDialog(
context: context,
builder: (context) {
final _multipleNotifier = Provider.of<MultipleNotifier>(context);
return AlertDialog(
title: Text("Select one country or many countries"),
content: SingleChildScrollView(
child: Container(
width: double.infinity,
child: Column(
mainAxisSize: MainAxisSize.min,
children: countries
.map((e) => CheckboxListTile(
title: Text(e),
onChanged: (value) {
value
? _multipleNotifier.addItem(e)
: _multipleNotifier.removeItem(e);
},
value: _multipleNotifier.isHaveItem(e),
))
.toList(),
),
),
),
actions: [
FlatButton(
child: Text("Yes"),
onPressed: () {
Navigator.of(context).pop();
},
),
],
);
},
);
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment