containerOf<T> static method

InternalIocInheritedWidget<T> containerOf<T>(
  1. BuildContext context
)

Retrieves the nearest InternalIocInheritedWidget container of type T.

Throws an assertion error if the container is not found.

Implementation

static InternalIocInheritedWidget<T> containerOf<T>(BuildContext context) {
  InternalIocInheritedWidget<T>? nullableContainer = maybeContainerOf(
    context,
  );
  assert(
    nullableContainer != null,
    "The requested container InternalIocInheritedWidget<$T>? is not registered in the widget tree.",
  );
  return nullableContainer!;
}