# doResolveDependency method

1. @override

Future<Object?> doResolveDependency(

1. DependencyDescriptor descriptor, [
2. Set<String>? autowiredPods

])
override

Abstract method that must be implemented by subclasses to resolve dependencies according to the specific factory implementation.

Example implementation:

    @override
    Future<Object?> doResolveDependency(DependencyDescriptor descriptor) async {
      // Check local registry first
      if (containsPod(descriptor.name)) {
        return getPod(descriptor.name);
      }

      // Fall back to parent factory
      return await parentFactory?.resolveDependency(descriptor);
    }

@param descriptor The dependency descriptor containing resolution information @return The resolved dependency object, or null if not resolvable

## Implementation

    @override
    Future<Object?> doResolveDependency(DependencyDescriptor descriptor, [Set<String>? autowiredPods]) async {
      // 1. Get type
      final type = descriptor.type;
      final podName = descriptor.podName;
      final lookup = descriptor.lookup;

      // 🔹 Special handling for ObjectFactory / ObjectProvider / (dart's class with the factory design)
      if (Class<ObjectFactory>(null, PackageNames.POD).isAssignableFrom(type) && !Class<ObjectProvider>(null, PackageNames.POD).isAssignableFrom(type)) {
        return _DependencyObjectFactory<Object>(descriptor, this);
      }

      if (Class<ObjectProvider>(null, PackageNames.POD).isAssignableFrom(type)) {
        return _DependencyObjectProvider<Object>(descriptor, this);
      }

      // 3. Handle Optional<T>
      if (Class<Optional>(null, PackageNames.LANG).isAssignableFrom(type)) {
        return await _DependencyOptional(this).resolve(descriptor);
      }

      if (lookup != null && lookup.isNotEmpty) {
        String dependencyName = targetName(lookup);

        if (await isTypeMatch(dependencyName, type) && isAutowireCandidate(dependencyName, descriptor) && !selfReferenced(podName, dependencyName)) {
          if (autowiredPods != null) {
            autowiredPods.add(dependencyName);
          }

          final result = await _get(dependencyName, type);
          return verifyInstance(result, type, dependencyName, descriptor);
        }
      }

      // Handle Stream<T>
      if (Class<Stream>(null, PackageNames.DART).isAssignableFrom(type)) {
        final result = await resolveMultipleCollectionPods(podName, descriptor, autowiredPods);
        if (result is List) {
          return Stream<Object>.fromIterable(List<Object>.from(result)).where((obj) => obj is! NullablePod);
        }

        return result != null ? Stream<Object>.value(result).where((obj) => obj is! NullablePod) : null;
      }

      // Handle GenericStream<T>
      if (Class<GenericStream>(null, PackageNames.LANG).isAssignableFrom(type)) {
        Object? result = await resolveMultipleCollectionPods(podName, descriptor, autowiredPods);
        if (result is List) {
          return GenericStream<Object>.of(List<Object>.from(result)).filter((obj) => obj is! NullablePod);
        }

        return result != null ? GenericStream<Object>.ofSingle(result).filter((obj) => obj is! NullablePod) : null;
      }

      // Handle Set<T>
      if (Class<Set>(null, PackageNames.DART).isAssignableFrom(type)) {
        final result = await resolveMultipleCollectionPods(podName, descriptor, autowiredPods);
        if (result is List) {
          return Set<Object>.from(result).where((obj) => obj is! NullablePod).toSet();
        }

        return result != null ? Set<Object>.from([result]).where((obj) => obj is! NullablePod).toSet() : null;
      }

      // Handle List<T> or arrays
      if (type.isArray() || Class<List>(null, PackageNames.DART).isAssignableFrom(type)) {
        final result = await resolveMultipleCollectionPods(podName, descriptor, autowiredPods);
        if (result is List) {
          return List<Object>.from(result).where((obj) => obj is! NullablePod).toList();
        }

        return result != null ? List<Object>.from([result]).where((obj) => obj is! NullablePod).toList() : null;
      }

      // Handle Map<String, T>
      if (type.isKeyValuePaired() || Class<Map>(null, PackageNames.DART).isAssignableFrom(type)) {
        final result = await resolveMultipleMappedPods(podName, descriptor, autowiredPods);
        if (result is Map) {
          final map = <String, Object>{};

          for (final entry in result.entries) {
            if (entry.value is! NullablePod) {
              map[entry.key] = entry.value;
            }
          }

          return map;
        }

        return result;
      }

      Map<String, Object> candidates = await findAutowireCandidates(podName, descriptor);
      if (candidates.isEmpty) {
        return notifyDependencyNotFound(podName, descriptor);
      }

      String? autowiredName;
    		Object? instanceCandidate;

      if (candidates.length > 1) {
        autowiredName = determineAutowireCandidate(candidates, descriptor);

        if (autowiredName == null) {
          if (isRequired(descriptor)) {
            return notifyMultipleCandidatesFound(type, candidates);
          } else {
            return null;
          }
        }

        instanceCandidate = candidates[autowiredName];
      } else {
        instanceCandidate = candidates.values.first;
        autowiredName = candidates.keys.first;
      }

      if (autowiredPods != null) {
        autowiredPods.add(autowiredName);
      }

      if (instanceCandidate != null) {
        final instance = convertIfNecessary(podName, instanceCandidate, type);
        return verifyInstance(instance, type, podName, descriptor);
      }

      return null;
    }