of<W extends Scope<W, D, S> , D extends ScopeDependencies, S extends ScopeState<W, D, S> > static method
S
of<W extends Scope<W, D, S> , D extends ScopeDependencies, S extends ScopeState<W, D, S> >(
- BuildContext context
override
Finds and returns the state S of the scope W from the given
context.
Throws on two conditions, not one: there is no such scope above
context, or there is one whose state does not exist yet. The state is
created in the ready branch, so a scope still waiting for its scopeKey,
still initializing, failed, or taken down by close() has none to give.
The message says which of the two it was, and what state the scope was
in — read it from below buildOnReady(), or check isInitialized
first.
Implementation
static S of<W extends Scope<W, D, S>, D extends ScopeDependencies,
S extends ScopeState<W, D, S>>(BuildContext context) =>
ScopeContext.of<W, _ScopeElement<W, D, S>>(
context,
listen: false,
)._stateOrThrow;