of<AppState, AppAction, AppEnvironment> static method
DependencyProvider<AppState, AppAction, AppEnvironment>
of<AppState, AppAction, AppEnvironment>(
- BuildContext context
Retrieves the DependencyProvider from the nearest Dependency ancestor.
Throws if no Dependency widget is found in the tree.
Implementation
static DependencyProvider<AppState, AppAction, AppEnvironment> of<AppState, AppAction, AppEnvironment>(
BuildContext context,
) {
final Dependency? dependency = context.dependOnInheritedWidgetOfExactType<Dependency>();
if (dependency == null) {
throw Exception('Dependency not found');
}
return dependency.dependencyProvider as DependencyProvider<AppState, AppAction, AppEnvironment>;
}