of<T extends Object> static method

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

Obtains the nearest Scope

If not found searches in GlobalScope.read

Throw ScopeNotFoundException if T not exist.

Implementation

static T of<T extends Object>(
  BuildContext context, {
  bool listen = false,
}) {
  T? value;
  value = maybeOf<T>(context, listen: listen);
  if (value == null) {
    throw ScopeNotFoundException(T);
  }
  return value;
}