findNestedNavKeyWithPages method
Tuple5<GlobalKey<NavigatorState> , String, T, List<RoutebornPage> , Object?>
findNestedNavKeyWithPages(
The second return parameter is the AppPage type's name.
This is purposed to be called from NestedRouterDelegate
.
Implementation
Tuple5<GlobalKey<NavigatorState>, String, T, List<RoutebornPage>, Object?>
findNestedNavKeyWithPages(
BuildContext context, {
/// Set this branch only when you want to use separate [Router] for each
/// branch.
/// By setting this parameter you get the navigator key
/// for the given branch from the [NavigationCrossroad.navigatorKeys].
/// Otherwise, the [NavigationCrossroad.navigatorKey] is used.
T? branch,
}) {
final node = _findAncestorPageNode(context);
if (node == null) {
throw NavigationStackError(
'Could not find AppPageNode from the current route.\n'
'Given context Route is not in the pages stack.');
}
if (node.crossroad == null) {
throw NavigationStackError(
'Ancestor AppPageNode of the context does not have '
'a navigation crossroad.');
}
if (branch == null) {
return Tuple5(
node.crossroad!.navigatorKey,
node.page.runtimeType.toString(),
node.crossroad!.activeBranch,
node.crossroad!.activeBranchStack.pageNodesStack
.map((e) => e.page)
.toList(),
node.crossroad!.branchParam,
);
} else {
return Tuple5(
node.crossroad!.navigatorKeys[branch]!,
node.page.runtimeType.toString(),
branch,
node.crossroad!.availableBranches[branch]!.pageNodesStack
.map((e) => e.page)
.toList(),
node.crossroad!.branchParams[branch],
);
}
}