getRootInjectable<T> static method

Injectable<T> getRootInjectable<T>()

Implementation

static Injectable<T> getRootInjectable<T>() {
  final states = _InheritedState._rootState!._states;
  final injectable = states.cast<Injectable<dynamic>?>().firstWhere(
      (injectable) => injectable!.type == T,
      orElse: () => null) as Injectable<T>?;
  if (injectable == null)
    throw Exception('${T.toString()} is not registered.');
  return injectable;
}