get<T> static method

T get<T>(
  1. BuildContext context
)

Implementation

static T get<T>(BuildContext context) {
  ScopeRegistrant? registrant = of(context);
  if (registrant != null) {
    dynamic instance = registrant.map[T];
    if (instance != null && instance != Null) {
      return instance as T;
    } else {
      throw Exception(
          "The Scope S you are trying to build with ScopeBuilder<S>() isn't registered with the ScopeRegistrant.");
    }
  } else {
    throw Exception(
        "There is no ScopeRegistrant above your ScopeBuilder<S> in the widget tree");
  }
}