findInThisScope<T> method

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

Find a dependency only in this specific scope (not in parents)

Implementation

T? findInThisScope<T>({String? tag}) {
  if (_disposed) {
    return null;
  }

  final key = _makeKey<T>(tag);

  if (tag != null) {
    // Check if this tag exists in this scope
    final instance = _taggedBindings[tag];
    if (instance != null && instance is T) {
      return instance;
    }

    // Check for factory
    if (_factories.containsKey(key)) {
      return _createFromFactory<T>(key, tag);
    }

    return null;
  } else {
    // Try to find by type in this scope only
    final instance = _typeBindings[T];
    if (instance != null) {
      return instance as T;
    }

    // Check for factory
    if (_factories.containsKey(key)) {
      return _createFromFactory<T>(key, null);
    }

    return null;
  }
}