of static method

Reads the nearest ProviderContainer from the widget tree.

Implementation

static ProviderContainer of(BuildContext context) {
  final inherited = context
      .dependOnInheritedWidgetOfExactType<_ProviderScopeInherited>();
  assert(inherited != null, 'No ProviderScope found in context');
  return inherited!.container;
}