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]) {
  var t2 = T;
  if (t != null) {
    t2 = t;
  } else if (T == dynamic && t == null) {
    return false;
  }

  Container? search = this;
  while (search != null) {
    if (search._singletons.containsKey(t2)) {
      return true;
    } else if (search._factories.containsKey(t2)) {
      return true;
    } else {
      search = search._parent;
    }
  }

  return false;
}