currentRequestScope top-level property

RequestScope? get currentRequestScope

Returns the RequestScope bound to the current zone, or null when called from outside a request (background jobs, tests that render a template directly, etc.).

Implementation

RequestScope? get currentRequestScope {
  final v = Zone.current[_requestScopeKey];
  return v is RequestScope ? v : null;
}