of static method

Looks up the nearest RouteScopeProvider for a specific scope aspect.

Throws a FlutterError when no provider exists above context.

Implementation

static RouteScopeProvider of(BuildContext context, RouteScope scope) {
  final model = InheritedModel.inheritFrom<RouteScopeProvider>(
    context,
    aspect: scope,
  );
  if (model != null) return model;
  throw FlutterError(
    'Unrouter ${scope.name} is unavailable in this BuildContext.',
  );
}