In my project i am setting up go_router navigation and it works great for navigate, but i found two issues in two cases which i am mentioning below.
- Not found a proper way to pass result in previous page
I have created a common function for routing in the whole app where i have defined all methods push, pop, remove. Now i need to setup a common method where i can pass some data into other screen and also need to get result in previos page when the second screen pop will going to be called.
static go(
{required BuildContext context,
required Mode mode,
required String moveTo,
var param}) async {
try {
switch (mode) {
case Mode.PUSH:
context.push(RouteName.root + moveTo);
break;
case Mode.REPLACE:
context.pushReplacement(RouteName.root + moveTo);
break;
case Mode.REMOVE:
context.go(RouteName.root);
context.pushReplacement(RouteName.root + moveTo);
break;
case Mode.POP:
context.pop();
break;
}
} catch (e) {
print(e);
}
}
- How to get page info during routing
In go_router i am unable to find a way where i can get the current page information if i pop the screen B to screen A. I need to track user activity so in this case i need to fetch the route info when user go or back into any screen. Please guide me if there is any way with go_router.