getDependency<T> static method

T getDependency<T>([
  1. Map<String, dynamic>? params,
  2. String tag = "global"
])

Use to inject a Dependency. If the Dependency is not instantiated, it starts a new instance. If it is marked as a singleton, the instance persists until the end of the application, or until the disposeDependency;

Implementation

static T getDependency<T>([Map<String, dynamic>? params, String tag = "global"]) {
  try {
    Core? core = _injectMapHelper.containsKey(tag) ? _injectMapHelper[tag] : _injectMap[tag];
    if (core == null) {
      throw BlocProviderException("Module \"$tag\" is not in the widget tree");
    }
    return core.dependency<T>(params);
  } on BlocProviderException {
    rethrow;
  } on NoSuchMethodError {
    rethrow;
  } catch (e) {
    throw e;
  }
}