of static method

ZenScope of(
  1. BuildContext context
)

Finds the nearest ZenScope above the given context.

Returns the scope or throws an exception if none is found.

Implementation

static ZenScope of(BuildContext context) {
  final _ZenScopeProvider? provider =
      context.dependOnInheritedWidgetOfExactType<_ZenScopeProvider>();
  if (provider == null) {
    throw ZenScopeNotFoundException(widgetType: 'ZenScopeWidget');
  }
  return provider.scope;
}