In flutter, when the user uses the back button, I want it to show a dialog to confirm they want to leave the page
I did this before using the following code:
AppScaffold(
body: WillPopScope(
onWillPop: () {
showLogoutDialog(context);
return false;
},
child: Contents(),
),
);
As WillPopScope
is now deprecated, how would I do this using the new PopScope
, or any other method?
PopScope
has a canPop
property, and onPopInvoked
which the documentation metions:
method is called; the pop has already happened. Use [canPop] to
disable pops in advance.