diff --git a/lib/mainwrapper.dart b/lib/mainwrapper.dart index 1663005..e0f3323 100644 --- a/lib/mainwrapper.dart +++ b/lib/mainwrapper.dart @@ -19,16 +19,32 @@ class MainWrapperState extends State { ]; Future _systemBackButtonPressed() async { - if (_navigatorKeys[_selectedIndex].currentState?.canPop() == true) { - _navigatorKeys[_selectedIndex] - .currentState - ?.pop(_navigatorKeys[_selectedIndex].currentContext); - return false; - } else { - SystemChannels.platform.invokeMethod('SystemNavigator.pop'); - return true; // Indicate that the back action is handled - } + if (_navigatorKeys[_selectedIndex].currentState?.canPop() == true) { + _navigatorKeys[_selectedIndex] + .currentState + ?.pop(_navigatorKeys[_selectedIndex].currentContext); + return false; + } else { + return await showDialog( + context: context, + builder: (context) => AlertDialog( + title: Text('Exit App'), + content: Text('Do you really want to exit the app?'), + actions: [ + TextButton( + onPressed: () => Navigator.of(context).pop(false), + child: Text('No'), + ), + TextButton( + onPressed: () => SystemChannels.platform.invokeMethod('SystemNavigator.pop'), + child: Text('Yes'), + ), + ], + ), + ) ?? false; } +} + @override Widget build(BuildContext context) {