has<T> method

bool has<T>([
  1. Type? t
])

Determines if the container has an injection of the given type.

Implementation

bool has<T>([Type? t]) {
  Container? search = this;
  t ??= T == dynamic ? t : T;

  while (search != null) {
    if (search._singletons.containsKey(t)) {
      return true;
    } else if (search._factories.containsKey(t)) {
      return true;
    } else {
      search = search._parent;
    }
  }

  return false;
}