Replies: 8 comments 12 replies
-
Also would be good to have a history of the stack with the ability to go back and forth like in Routemaster. |
Beta Was this translation helpful? Give feedback.
-
During the first, the navigator is not build yet (since the building of the
This is because the |
Beta Was this translation helpful? Give feedback.
-
I have much to say about this but you should open another issue since this has nothing to do with your first question :) |
Beta Was this translation helpful? Give feedback.
-
@csells imo this should remain as an issue |
Beta Was this translation helpful? Give feedback.
-
This isn't an issue w/ go_router but a question about proper use, which has been answered: #212 (comment) |
Beta Was this translation helpful? Give feedback.
-
Actually #212 (comment) was more about a "flaw" in The real solution to @agondev is to use WidgetsBinding.instance!.addPostFrameCallback((_) => appRouter.navigator?.pop()) This looks bad but this is kind of an extreme case since you do 2 unusual things:
There is nothing wrong with that, all I'm saying is that even if the solution is not very intuitive its ok because not many people will encounter it. |
Beta Was this translation helpful? Give feedback.
-
Imo GoRouter should have awareness of what the current location in the stack is, and pop it on demand after registering the callback from one place for convenience (keyboard shortcuts) instead of relying on each individual screen to implement the same "wrap with pop context in multiple locations" |
Beta Was this translation helpful? Give feedback.
-
It's already the case. I don't know why Anyway this would not solve your issue, you are trying to I gave you a solution which would not require you to "relying on each individual screen to implement the same wrap with pop context in multiple locations", just keep the same code you have and wrap your |
Beta Was this translation helpful? Give feedback.
-
By wrapping the MaterialApp's builder's child with CallbackShortcut and passing various options of popping route, like
Navigator.of(context)
or
context.pop()
or
GoRouterDelegate
or
_goRouter.pop()
or
Router.of(context).routerDelegate.popRoute()
etc.
I get exceptions like
Router operation requested with a context that does not include a Router.
and
No GoRouter found in context
.Only thing that seems to kind of work is appRouter.navigator?.pop(), and that requires 2 attempts after the first time. With Auto Route it's enough to call
_autoRoute.pop()
from anywhere in the app using a shortcut of my choosing for it to pop the closest encompassing route.Can the same not be done in GoRouter?
Example of my latest draft of MaterialApp
To reiterate, the first binding works in GoRouter after two attempts, the second one just throws. But it does work in Auto Route with no problems.
Beta Was this translation helpful? Give feedback.
All reactions