didReplace method
The Navigator replaced oldRoute
with newRoute
.
Implementation
@override
void didReplace({Route? newRoute, Route? oldRoute}) {
super.didReplace(newRoute: newRoute, oldRoute: oldRoute);
final newName = _extractRouteName(newRoute);
final oldName = _extractRouteName(oldRoute);
final currentRoute = _RouteData.ofRoute(oldRoute);
Get.log("REPLACE ROUTE $oldName");
Get.log("NEW ROUTE $newName");
if (newRoute != null) {
RouterReportManager.instance.reportCurrentRoute(newRoute);
}
_routeSend?.update((value) {
// Only PageRoute is allowed to change current value
if (newRoute is PageRoute) {
value.current = newName ?? '';
}
value.args = newRoute?.settings.arguments;
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 is GetPageRoute) {
RouterReportManager.instance.reportRouteWillDispose(oldRoute);
}
routing?.call(_routeSend);
}