7

In flutter, I've a use case where I want to bring back the same route on top of the screen if its already present, otherwise push a new route.

As an example, Current stack : A -> B -> C -> D (top most)

If I push B, I just want A -> C -> D -> B. I want to bring B to the front with its state.

I went through the documentation but couldn't figure out a way to do this. Has someone figure out a way to do this?

Avi Yadav
  • 103
  • 1
  • 5
  • If B is already present as in your example, do you want the state of B to be mantained? – Naslausky Jul 24 '20 at 14:11
  • check this [question](https://stackoverflow.com/questions/62729903/navigating-through-materialpageroute) might help – dev-aentgs Jul 24 '20 at 14:12
  • Yes Naslausky, I wanted B's state to be maintained. – Avi Yadav Jul 24 '20 at 14:47
  • Navigation wise, this looks confusing. User mentally keeps trace of what's been doing, so if you want to push a previous route exactly with its current state, will give a weird experience to the user because he knows that he pushed A -> B -> C ->, then suddenly, he pushes (not pops) a new B screen that's exactly the same state of previous and last but not least, he pops all the stack and notices that the "old" B is no longer present. This can raise up many issues IMO. It's ok to push a new B, but you should keep the old one as it is or at most, pop it but not replacing the new route with it. – Miguel Ruivo Jul 24 '20 at 15:14
  • 3
    Miguel, if you look at the youtube navigation for home, explore, notifications tab.... , this is how they have built it. – Avi Yadav Jul 24 '20 at 15:16

0 Answers0