-1

I have a scenario where I have PageA, PageB, PageC. From PageA I can go to PageB, from PageB I can go to PageC, from PageC I have to go to PageB where clicking on back of PageB should land me on PageC. The problem here is this can open many instances. For example, PageC -> PageB -> PageC -> PageB -> PageC -> PageB etc.. and in this scenario when back clicks occur it will go back as PageB -> PageC -> PageB -> PageC -> PageB -> PageC and so on.. What I want to implement is this: PageA -> PageB -> PageC -> PageB -> PageC If back click is on PageC it should always go back to PageB. If PageB is opened from PageC it should go back to PageC then back leads to PageB then back leads to PageA, that is maximum of two times PageB to be opened. Any help on how to implement this in flutter. I'm using Getx to navigate between pages.

Zayd Khan
  • 124
  • 2
  • 11

1 Answers1

0

Use these codes provided by flutter material app to navigate through pages

This is for going forward or going to the next page.

Navigator.of(context).push(
MaterialPageRoute(builder: (BuildContext context){
return <Page you want to go>;
},),);

Use this to go back

Navigator.of(context).pop();

This works like a stack . You push the page you want to go and when you go back the page is poped . Use this methos and you can navigate A->B->C->B->C

Vivek T
  • 1
  • 1
  • This works like a stack exactly, which means i can go B->C -> B -> C countless times, when back is clicked it will pop items from stack, but i want B to be opened just twice, once from A and another from C and if anytime it is called again it should reopen the opened one – Zayd Khan Aug 12 '21 at 13:26