What i need is that when user clicking on home and recent button first alert must come "do you want to exit the app" then again tapping once more app must be closed
i tried using app life cycle but not working properly
What i need is that when user clicking on home and recent button first alert must come "do you want to exit the app" then again tapping once more app must be closed
i tried using app life cycle but not working properly
2
Answers
You can do it using
PopScope
. Where you can prevent system back gestures usingcanPop
.you can also use
onPopInvoked
parameter if you want.To use
PopScope
just wrap your Widget with it and show AlertDialog:For more information about
PopScope
you can check documentation here: PopScopeWillPopScope is deprecated after v3.12.0
You can use the new PopScope class (Flutter SDK 3.16.x or greater)