Reputation: 5381
I have 2 screens - screen A and screen B. I navigate from screen A to screen B.
I want to take some particular action when I am coming BACK to screen A by popping out screen B from the navigation stack.
I know I can use didUpdateWidge
but I can't figure out an efficient way of doing it.
Is using Inherited Widget
the correct way here?
Upvotes: 0
Views: 114
Reputation: 51751
Navigator.push[Named]
returns a Future
that completes when screen B pops. So add the code you want to execute after the pop to then
.
Navigator.pushNamed(context, '/someRoute').then((_) {/* do stuff here */});
Upvotes: 1
Reputation: 366
Try to use WillPopScope. This widget allows to catch back button press.
Upvotes: 0