has<T> method

bool has<T>()

Checks whether a provider or override for type T is registered in this container or its ancestors.

Returns true if type T can be resolved without throwing; otherwise false.

if (container.has<NotificationService>()) {
  container.inject<NotificationService>().notify('Ready');
}

Implementation

bool has<T>() =>
    _overrides.containsKey(T) ||
    _bindings.containsKey(T) ||
    (parent?.has<T>() ?? false);