Restore Route with Flutter Navigation

Viewed 648

Is there any way to push an already active route?

Navigator.push(context, onceUsedRoute);

I have navigation for three different routes and I really liked to preserve the state of each route and corresponding widget while switching between them.

For different reasons I am dependent on the Flutter Navigator for the navigation, so substituting Widgets in the render tree is not really an option.

The Navigator class does not provide any way to return to a past route without popping all later routes. There isn't even a possibility to read the routes that the Navigator stores right in its _history-field.

I tried storing the different routes myself, but even then an assertion

assert(newRoute._navigator == null)

prohibits re-pushing a route, no matter if it's with the same navigator. And of course, it's not possible to reset the _navigator attribute in the routes.

I know that the Navigator preserves all old routes, including their state because you can easily access them by popping the route stack.

How can this be so hard? Am I missing something essential?

0 Answers
Related