Difficulty navigating through the various screens of my flutter app

Issue

I need to scroll through my app screens. The Navigator is not enough for me because there are cases where I should go back to a screen that has never been created.

Just think of a 5-step process: if the application is stopped during the third step, the next time it starts it will resume from this and not from the first.
By doing this, if I wanted to go back from the third process, I couldn’t do it because the third screen was created directly.

I’ve tried working with a PageView but that’s not what I’m looking for. I have to somehow change the screens stack or launch multiple screens at the same time when the app starts.

Solution

You can use auto_route or go_router to push multiple pages at once. The setup varies between the two but the end result is the same – instead of pushing one page onto the navigator stack, you can push a whole list of them.

For example, if you know what page the user left off on, you can push them back to that screen when the app first opens:

AutoRouter.of(context).pushAll([
  PageOneRoute(),
  PageTwoRoute(),
  PageThreeRoute(),
])

Answered By – Joe Muller

Answer Checked By – Terry (FlutterFixes Volunteer)

Leave a Reply

Your email address will not be published.