of static method

PodContainer of(
  1. BuildContext context, {
  2. bool listen = true,
})

Read the current PodContainer for a BuildContext.

Implementation

static PodContainer of(
  BuildContext context, {
  bool listen = true,
}) {
  UncontrolledPodScope? scope;

  scope = listen
      ? context //
          .dependOnInheritedWidgetOfExactType<UncontrolledPodScope>()
      : (context
          .getElementForInheritedWidgetOfExactType<UncontrolledPodScope>()
          ?.widget as UncontrolledPodScope?);

  if (scope == null) {
    throw StateError('No PodScope found');
  }

  return scope.container;
}