tryBuild method

  1. @visibleForTesting
Widget tryBuild(
  1. BuildContext context,
  2. RouteMatchList matchList,
  3. bool routerNeglect,
  4. GlobalKey<NavigatorState> navigatorKey,
  5. Map<Page<Object?>, GoRouterState> registry,
)

Builds the top-level Navigator by invoking the build method on each matching route.

Throws a _RouteBuilderError.

Implementation

@visibleForTesting
Widget tryBuild(
  BuildContext context,
  RouteMatchList matchList,
  bool routerNeglect,
  GlobalKey<NavigatorState> navigatorKey,
  Map<Page<Object?>, GoRouterState> registry,
) {
  // TODO(chunhtai): move the state from local scope to a central place.
  // https://github.com/flutter/flutter/issues/126365
  final _PagePopContext pagePopContext =
      _PagePopContext._(onPopPageWithRouteMatch);
  return builderWithNav(
    context,
    _buildNavigator(
      pagePopContext.onPopPage,
      _buildPages(context, matchList, pagePopContext, routerNeglect,
          navigatorKey, registry),
      navigatorKey,
      observers: observers,
      restorationScopeId: restorationScopeId,
      requestFocus: requestFocus,
    ),
  );
}