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,
) {
  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 as GoRoute).redirectOnly);
  return builderWithNav(
    context,
    Builder(
      builder: (BuildContext context) {
        final Map<Page<Object?>, GoRouterState> newRegistry =
            <Page<Object?>, GoRouterState>{};
        final Widget result = tryBuild(context, matchList, routerNeglect,
            configuration.navigatorKey, newRegistry);
        _registry.updateRegistry(newRegistry);
        return GoRouterStateRegistryScope(registry: _registry, child: result);
      },
    ),
  );
}