of<W extends ScopeCore<W, E, D, S> , E extends ScopeCoreElement<W, E, D, S> , D extends ScopeDependencies, S extends ScopeCoreState<W, E, D, S> > static method
S
of<W extends ScopeCore<W, E, D, S> , E extends ScopeCoreElement<W, E, D, S> , D extends ScopeDependencies, S extends ScopeCoreState<W, E, 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 use maybeOf, which
answers null instead of throwing.
Implementation
static S of<
W extends ScopeCore<W, E, D, S>,
E extends ScopeCoreElement<W, E, D, S>,
D extends ScopeDependencies,
S extends ScopeCoreState<W, E, D, S>
>(BuildContext context) =>
ScopeInheritedContext.of<W, E>(context, listen: false)._stateOrThrow;