Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- Widget build(BuildContext context) {
- return WillPopScope(
- onWillPop: _onExit,
- child: Scaffold();
- Future<bool> _onExit() async {
- return showDialog(
- context: context,
- builder: (context) => AlertDialog(
- title: Text("Exit"),
- content: Text("Do you want to exit?"),
- actions: <Widget>[
- RaisedButton(
- child: Text(
- "Nope",
- ),
- onPressed: () => Navigator.of(context).pop(),
- ),
- FlatButton(
- child: Text(
- "Yes",
- style: TextStyle(color: Colors.red[200]),
- ),
- onPressed: () => exit(0)),
- ],
- ));
- }
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement