0

I want to navigate the user to home screen and delete the previous navigation stack after pressed some button on another screen. For the time being I used Navigator.pushNamedAndRemoveUntil method for that. but the case is when I pressed the device back button on home screen my application crash So I wand to handle or override the device back button action.

1
  • You might want to include a stacktrace to make it easier for whoever wishes to answer your question. Commented Apr 28, 2021 at 18:46

2 Answers 2

0

use WillPopScope widget like this

return new WillPopScope(
    onWillPop: () async {
   //  your logic here 
   //  
   return Future.value(false); // true if you want the back button to take effect 
},
    child: new Scaffold(
     //then the rest of your code...
Sign up to request clarification or add additional context in comments.

Comments

0

This answer is outdated. you can use either popscope() or override dispose() functions.

Comments

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.