Follow

Keep Up to Date with the Most Important News

By pressing the Subscribe button, you confirm that you have read and are agreeing to our Privacy Policy and Terms of Use
Contact

how do I know if a page is pushed or not in navigation stack?

let say I have 2 pages, PageA and PageB.

if a user tap a button in PageA then it will move to PageB using the code below

Navigator.of(context).pushNamed("pageB");

so as a result, there is back button in the top left app bar in PageB

MEDevel.com: Open-source for Healthcare and Education

Collecting and validating open-source software for healthcare, education, enterprise, development, medical imaging, medical records, and digital pathology.

Visit Medevel

my question is …..

how do I know if a page is pushed or not? I want to do something only if there is a back button in the appbar in a page

>Solution :

You can use this:

final hasPagePushed = Navigator.of(context).canPop();

This is actually what the flutter’s AppBar is using to know whether or not it should display the back button.

Add a comment

Leave a Reply

Keep Up to Date with the Most Important News

By pressing the Subscribe button, you confirm that you have read and are agreeing to our Privacy Policy and Terms of Use

Discover more from Dev solutions

Subscribe now to keep reading and get access to the full archive.

Continue reading