of static method

Implementation

static ZenithContainer of(BuildContext context) {
  final inherited = context
      .dependOnInheritedWidgetOfExactType<_ZenithScopeInherited>();

  assert(inherited != null, 'No ZenithScope found in BuildContext hierarchy');

  final container = inherited!.container;
  assert(
    !container.isDisposed,
    'Attempted to access a disposed ZenithContainer from BuildContext',
  );

  return container;
}