build method

Widget build(
  1. BuildContext context,
  2. RouteMatchList matchList,
  3. bool routerNeglect
)

Builds the top-level Navigator for the given RouteMatchList.

Implementation

Widget build(
  BuildContext context,
  RouteMatchList matchList,
  bool routerNeglect, // TODO(tolo): This parameter is not used and should be
  // removed in the next major version.
) {
  if (matchList.isEmpty && !matchList.isError) {
    // The build method can be called before async redirect finishes. Build a
    // empty box until then.
    return const SizedBox.shrink();
  }
  assert(matchList.isError || !matchList.last.route.redirectOnly);
  return builderWithNav(
    context,
    _CustomNavigator(
      // The state needs to persist across rebuild.
      key: GlobalObjectKey(configuration.navigatorKey.hashCode),
      navigatorKey: configuration.navigatorKey,
      observers: observers,
      navigatorRestorationId: restorationScopeId,
      onPopPageWithRouteMatch: onPopPageWithRouteMatch,
      matchList: matchList,
      matches: matchList.matches,
      configuration: configuration,
      errorBuilder: errorBuilder,
      errorPageBuilder: errorPageBuilder,
    ),
  );
}