of<T> static method

T of<T>(
  1. BuildContext context
)

Obtains the provided resource of type T from the widget tree.

This method searches up the widget tree for a JoltProvider of type T and returns its provided resource.

Throws

Throws an exception if no JoltProvider of type T is found in the widget tree. Use maybeOf if the provider may not exist.

Example

final store = JoltProvider.of<MyStore>(context);

Implementation

static T of<T>(BuildContext context) {
  return context
      .dependOnInheritedWidgetOfExactType<_JoltProviderData<T>>()!
      .data;
}