You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
We investigated an issue in our app after upgrading to the latest version of auto_route where if we have 2 routes of the same type in the stack, try to remove the second one using context.router.removeWhere, the topmost route is being removed.
context.pushRoute(
InfoRoute(
canPop:false,
content: [
successScreen(),
],
),
);
/// To keep the fade-in-out animation of the loader, /// we must just push the success screen instead of replacing the loader route. /// When closing the success screen the loader is visible for a little while, /// so the solution is to remove it like this.awaitFuture.delayed(RouteConstants.routeClosureDelayDuration.ms);
if (context.mounted) {
context.router.removeWhere(
(route) => route.isInfoRoute(withKey: loaderKey),
);
}
extensionRouteDataExtensionsonRouteData {
/// Can be used to conveniently check if the Route is [InfoRoute].boolisInfoRoute({ValueKey? withKey}) {
final args =this.args;
if (args is!InfoRouteArgs) {
returnfalse;
}
if (withKey !=null) {
return args.key == withKey;
}
returntrue;
}
}
This used to work just fine before the only difference was how we identify the route using the key, the key used to be in RouteData, now it lives in the argument class (InfoRouteArgs)
After investigating this we found the root cause which is in routing_controller.dart:
void_removeRoute(RouteMatch route, {bool notify =true}) {
var pageIndex = _pages.lastIndexWhere((p) => p.routeKey == route.key);
if (pageIndex !=-1) {
_pages.removeAt(pageIndex);
}
_updateSharedPathData(includeAncestors:true);
_removeTopRouterOf(route.key);
if (notify) {
notifyAll(forceUrlRebuild:true);
}
}
It used the route key to identify the route, however this key is the same for both screens, the key is set to the route's name which is InfoRoute.
The text was updated successfully, but these errors were encountered:
@Milad-Akarie hi sir! Any chance you could guide us on how to resolve this issue? Is there any way to help AutoRoute to distinguish two different routes of the same type based on custom conditions?
We investigated an issue in our app after upgrading to the latest version of auto_route where if we have 2 routes of the same type in the stack, try to remove the second one using
context.router.removeWhere
, the topmost route is being removed.Here's an example:
Then after loading is completed:
This used to work just fine before the only difference was how we identify the route using the key, the key used to be in
RouteData
, now it lives in the argument class (InfoRouteArgs
)After investigating this we found the root cause which is in
routing_controller.dart
:It used the route key to identify the route, however this key is the same for both screens, the key is set to the route's name which is
InfoRoute
.The text was updated successfully, but these errors were encountered: