existsInThisScope<T> method

bool existsInThisScope<T>({
  1. String? tag,
})

Check if a dependency exists (instance or lazy factory) in this scope only, without triggering lazy factory instantiation.

Implementation

bool existsInThisScope<T>({String? tag}) {
  if (_disposed) return false;

  final key = _makeKey<T>(tag);
  if (_factories.containsKey(key)) return true;

  if (tag != null) {
    if (_taggedBindings[T]?.containsKey(tag) ?? false) return true;
    for (final tagMap in _taggedBindings.values) {
      final candidate = tagMap[tag];
      if (candidate != null && candidate is T) {
        return true;
      }
    }
    return false;
  }

  return _typeBindings.containsKey(T);
}