of<T> static method

T of<T>(
  1. BuildContext context, {
  2. bool listen = true,
})

Retrieves the nearest SolidProvider of type T from the widget tree. Throws an error if no provider is found.

Implementation

static T of<T>(BuildContext context, {bool listen = true}) {
  final inherited = maybeOf<T>(context, listen: listen);
  if (inherited == null) {
    throw FlutterError(
      'Could not find SolidProvider<$T> in the ancestor widget tree. '
      'Make sure you have a SolidProvider<$T> widget as an ancestor of the '
      'widget that is trying to access it.',
    );
  }
  return inherited;
}