dependency<T> method

T dependency<T>({
  1. bool existingInstance = true,
})

Implementation

T dependency<T>({bool existingInstance = true}) {
  try {
    if (existingInstance) {
      return (_cache[T] ?? (_cache[T] = _factory[T]!())) as T;
    } else {
      return _factory[T]!() as T;
    }
  } catch (e) {
    throw DependencyNotFoundException<T>();
  }
}