navigatorKeyForSubRoute method

  1. @override
GlobalKey<NavigatorState> navigatorKeyForSubRoute(
  1. RouteBase subRoute
)
override

Returns the key for the Navigator that is to be used for the specified immediate sub-route of this shell route.

Implementation

@override
GlobalKey<NavigatorState> navigatorKeyForSubRoute(RouteBase subRoute) {
  final StatefulShellBranch? branch = branches.firstWhereOrNull(
      (StatefulShellBranch e) => e.routes.contains(subRoute));
  assert(branch != null);
  return branch!.navigatorKey;
}