runLoader method

FutureOr<Object?> runLoader(
  1. RequestContext context,
  2. RouteMatches matches
)

Runs this route's loader for the active branch.

Implementation

FutureOr<Object?> runLoader(RequestContext context, RouteMatches matches) {
  final loader = load;
  if (loader == null) return const NoData();
  final match = matches.match(this);
  if (match == null) {
    throw StateError('Server route is not part of the active route branch.');
  }
  return loader(
    ServerLoadContext<P, S>(
      context: context,
      params: match.params,
      search: match.search,
      location: matches.location,
      branch: matches.branch,
    ),
  );
}