buildTopLevelGoRouterState method

GoRouterState buildTopLevelGoRouterState(
  1. RouteMatchList matchList
)

Builds a GoRouterState suitable for top level callback such as GoRouter.redirect or GoRouter.onException.

Implementation

GoRouterState buildTopLevelGoRouterState(RouteMatchList matchList) {
  return GoRouterState(
    this,
    uri: matchList.uri,
    // No name available at the top level trim the query params off the
    // sub-location to match route.redirect
    fullPath: matchList.fullPath,
    pathParameters: matchList.pathParameters,
    matchedLocation: matchList.uri.path,
    extra: matchList.extra,
    pageKey: const ValueKey<String>('topLevel'),
    topRoute: matchList.lastOrNull?.route,
  );
}