# autowirePod method

1. @override

Future<void> autowirePod(

1. Object existing,
2. Class type, {
3. int? autowireMode,
4. bool? checkDependency,

})
override

Performs autowiring on an existing pod instance.

This method injects dependencies into an already created pod instance. It's useful for cases where you need to manually control instance creation but still want dependency injection benefits.

## Usage Example:

    final controller = MyController(); // Created manually
    await factory.autowirePod(controller, Class<MyController>());
    // Now controller has all dependencies injected

@param existingPod The pod instance to autowire @param type The class type of the pod @param autowireMode The autowiring mode to use @param checkDependency Whether to check dependency validity @return A Future that completes when autowiring is done

## Implementation

    @override
    Future<void> autowirePod(Object existing, Class type, {int? autowireMode, bool? checkDependency}) async {
      // Use non-singleton pod definition, to avoid registering pod as dependent pod.
      RootPodDefinition root = RootPodDefinition(type: type)
        ..scope = ScopeDesign.type(ScopeType.PROTOTYPE.name)
        ..instance = existing;

      // Set autowire mode if provided
      if (autowireMode != null) {
        root.autowireCandidate = AutowireCandidateDescriptor(autowireCandidate: true, autowireMode: AutowireMode.fromValue(autowireMode));
      }

      // Set dependency check if provided
      if (checkDependency != null) {
        root.dependencyCheck = checkDependency
          ? type.getFields().all((f) => !f.isNullable())
            ? DependencyCheck.ALL
            : DependencyCheck.OBJECTS
          : DependencyCheck.NONE;
      }

      await populate(root.type.getName(), root, (existing, type));
    }