I want to exit the alert.
WillPopScope(
onWillPop: () async {
final shouldExit = await showDialog(
context: context,
builder: (context) => CupertinoAlertDialog(
title: const Text('Exit App'),
content: const Text('Are you sure you want to exit the app?'),
actions: [
CupertinoDialogAction(
onPressed: () => Navigator.pop(context, false),
child: const Text('Dismiss'),
),
TextButton(
onPressed: () => Navigator.pop(context, true),
child: Text(
'Exit',
style:
TextStyle(color: Theme.of(context).colorScheme.error),
),
),
],
),
);
return shouldExit;
},
2
Answers
PopScope( canPop: false, onPopInvoked: (didPop) async { debugPrint("didPop1: $didPop"); if (didPop) { return; }
you can try this solution