of<D extends Drip> static method

D of<D extends Drip>(
  1. BuildContext context, {
  2. bool listen = false,
})

Implementation

static D of<D extends Drip>(BuildContext context, {bool listen = false}) {
  if (D == dynamic) {
    throw ProviderError();
  }

  final provider = listen
      ? context.dependOnInheritedWidgetOfExactType<_DripProviderIW<D>>()
      : (context.getElementForInheritedWidgetOfExactType<_DripProviderIW<D>>()?.widget as _DripProviderIW<D>?);

  if (provider == null) {
    throw ProviderError(D);
  }

  return provider.drip;
}