reportDependencyLinkedToRoute method
Links a Class instance S (or tag) to the current route.
Requires usage of GetMaterialApp.
When the registration being resolved was declared by a page binding
(ownerRouteName is not null) and the current route is not the
declaring page's route, the dependency is linked to the declaring
page's installed route instead — so a parent page's controller first
resolved under a deep-linked child route still belongs to the parent
route and survives the child's disposal. When no route named
ownerRouteName is installed (e.g. the parent page was never
mounted), the link falls back to the current route.
Implementation
void reportDependencyLinkedToRoute(
String dependencyKey, {
String? ownerRouteName,
}) {
var target = _current;
if (ownerRouteName != null && !_routeIsNamed(target, ownerRouteName)) {
target = _latestRouteNamed(ownerRouteName) ?? target;
}
if (target == null) return;
if (_routesKey.containsKey(target)) {
_routesKey[target]!.add(dependencyKey);
} else {
_routesKey[target] = <String>[dependencyKey];
}
}