didReplace method
The Navigator replaced oldRoute
with newRoute
.
Implementation
@override
void didReplace({Route<dynamic>? newRoute, Route<dynamic>? oldRoute}) {
super.didReplace(newRoute: newRoute, oldRoute: oldRoute);
final newName = _extractRouteName(newRoute);
final oldName = _extractRouteName(oldRoute);
final currentRoute = _RouteData.ofRoute(oldRoute);
logV("REPLACE ROUTE $oldName");
logV("NEW ROUTE $newName");
if (newRoute != null) {
RouterReportManager.reportCurrentRoute(newRoute);
}
routing?.update((value) {
// Only PageRoute is allowed to change current value
if (newRoute is PageRoute) {
value.current = newName ?? '';
}
value.route = newRoute;
value.isBack = false;
value.removed = '';
value.previous = '$oldName';
value.isBottomSheet =
currentRoute.isBottomSheet ? false : value.isBottomSheet;
value.isDialog = currentRoute.isDialog ? false : value.isDialog;
});
if (oldRoute?.settings is MaterialPage) {
RouterReportManager.reportRouteWillDispose(oldRoute!);
}
if (routing != null && Go.routingQueue.isNotEmpty) {
Go.routingQueue.removeLast();
Go.routingQueue.add(routing!.copyWith());
}
}