Use Case
I'm using go_router_builder and have three routes
HomeRouteData, Details1RouteData, and Details2RouteData, corresponding to HomePage, Details1Page, and Details2Page.
On HomePage, I push Details1Page and wait for a returned result. here
On Details1Page, I push Details2Page and wait for a result. here
On Details2Page, I pop to return to Details1Page. here
At that point, I continue to pop to go back to HomePage from Details1Page, but I can’t. here
After investigating the root cause, I found that the issue is due to the onExit callback always being passed into the GoRoute constructor.
Proposal
Option 1:
Use a variable similar to caseSensitive to determine whether this route implements the onExit callback.
const TypedGoRoute({
required this.path,
this.name,
this.routes = const <TypedRoute<RouteData>>[],
this.caseSensitive = true,
this.overrideOnExit = false,
});
Option 2:
Check whether the child route actually overrides the onExit function at the time build_runner runs: go_router_builder
final bool hasOverriddenOnExit = classElement.methods.any(
(method) => method.name == 'onExit',
);
Use Case
I'm using go_router_builder and have three routes
HomeRouteData, Details1RouteData, and Details2RouteData, corresponding to HomePage, Details1Page, and Details2Page.
On HomePage, I push Details1Page and wait for a returned result. here
On Details1Page, I push Details2Page and wait for a result. here
On Details2Page, I pop to return to Details1Page. here
At that point, I continue to pop to go back to HomePage from Details1Page, but I can’t. here
After investigating the root cause, I found that the issue is due to the onExit callback always being passed into the GoRoute constructor.
Proposal
Option 1:
Use a variable similar to caseSensitive to determine whether this route implements the onExit callback.
Option 2:
Check whether the child route actually overrides the onExit function at the time build_runner runs: go_router_builder