isInstantiated<S> method

bool isInstantiated<S>({
  1. String? tag,
})

Returns true if the dependency S has already been instantiated.

This checks if the lazy builder has executed or if the instance was put directly.

Implementation

bool isInstantiated<S>({String? tag}) {
  final key = _getKey<S>(tag);
  final local = _registry[key];
  if (local != null) {
    return local.isInstantiated;
  }
  final canonicalKey = _aliases[key];
  if (canonicalKey != null) {
    return _registry[canonicalKey]?.isInstantiated ?? false;
  }
  if (_parentScope != null) return _parentScope!.isInstantiated<S>(tag: tag);
  return false;
}