Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- @override
- Widget build(BuildContext context) {
- return PopScope(
- canPop: false,
- onPopInvokedWithResult: (didPop, result) {
- if (didPop) {
- return;
- }
- showExitPopup(context);
- },
- child: Scaffold(
- )
- }
- Future<bool> showExitPopup(context) async {
- return await showDialog(
- context: context,
- builder: (BuildContext context) {
- return AlertDialog(
- content: SizedBox(
- height: 90,
- child: Column(
- crossAxisAlignment: CrossAxisAlignment.start,
- children: [
- Text("Do you want to exit?"),
- SizedBox(height: 20),
- Row(
- children: [
- Expanded(
- child: ElevatedButton(
- onPressed: () {
- if (kDebugMode) {
- print('yes selected');
- }
- exit(0);
- },
- style: ElevatedButton.styleFrom(
- backgroundColor: ProjectColors.appbarColor),
- child: Text(
- "Yes",
- style: TextStyle(color: ProjectColors.white),
- ),
- ),
- ),
- SizedBox(width: 15),
- Expanded(
- child: ElevatedButton(
- onPressed: () {
- Navigator.of(context).pop();
- },
- style: ElevatedButton.styleFrom(
- backgroundColor: Colors.white,
- ),
- child:
- Text("No", style: TextStyle(color: Colors.black)),
- ))
- ],
- )
- ],
- ),
- ),
- );
- });
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement