Reputation: 344
I am having a problem when I am trying to use a checkboxlisttile in an alertdialog. I can see the list tile, but it doesn't change anything when I click on that, there won't be a tick.
bool imp = false
Future _showAlert(BuildContext context) {
return showDialog(
context: context,
child: AlertDialog(
title: Text('Add'),
content: Container(
child: Column(
children: <Widget>[
TextField(),
CheckboxListTile(
title: Text('Important:'),
value: imp,
onChanged: (value) {
setState(() {
imp = value;
});
},
),
],
),
),
),
);
}
Upvotes: 1
Views: 1473
Reputation: 2802
Just Add this 2 lines to your onchange method
onChanged: (value) {
setState(() {
imp = value;
});
Navigator.of(context).pop(); // Line 1
_showAlert(context) ;// Line 2
},
Upvotes: 1