of static method

Injector of(
  1. BuildContext context
)

Gets an Injector from a ]BuildContext]

Implementation

static Injector of(BuildContext context) {
  final injectorWidget =
      context.dependOnInheritedWidgetOfExactType<_InjectorInheritedWidget>();
  if (injectorWidget == null) {
    throw InjectorWidgetError._internal(
        "No `InjectorWidget` was found in the context.");
  }
  return injectorWidget.injector;
}