1showDialog(
2 context: context,
3 builder: (_) {
4 return AlertDialog(
5 title: Text('Wanna Exit?'),
6 actions: [
7 FlatButton(
8 onPressed: () => Navigator.pop(context, false), // passing false
9 child: Text('No'),
10 ),
11 FlatButton(
12 onPressed: () => Navigator.pop(context, true), // passing true
13 child: Text('Yes'),
14 ),
15 ],
16 );
17 }).then((exit) {
18 if (exit == null) return;
19
20 if (exit) {
21 // user pressed Yes button
22 } else {
23 // user pressed No button
24 }
25});