# getProvider<T> method

1. @override

Future<ObjectProvider<T>> getProvider<T>(

1. Class<T> type, {
2. String? podName,
3. bool allowEagerInit = false,

})
override

Retrieves a provider for a pod, allowing for lazy or eager initialization.

A provider gives more control over when and how a pod is instantiated. This is useful for lazy loading or when you need to manage the lifecycle of pods more precisely.

## Usage Example:

    final provider = await factory.getProvider<DatabaseService>(
      'databaseService',
      Class<DatabaseService>(),
      allowEagerInit: true,
    );

    // Get the instance when needed
    final database = await provider.get();

@param podName The name of the pod to provide @param type The class type of the pod @param allowEagerInit Whether to allow eager initialization @return A Future that completes with an ObjectProvider for the pod

## Implementation

    @override
    Future<ObjectProvider<T>> getProvider<T>(Class<T> type, {String? podName, bool allowEagerInit = false}) async {
      final objects = <ObjectHolder<T>>[];
      final result = await getPodsOf<T>(type, includeNonSingletons: true, allowEagerInit: allowEagerInit);
      if (result.isNotEmpty) {
        for (final value in result.values) {
          objects.add(ObjectHolder<T>(value, qualifiedName: type.getQualifiedName(), packageName: type.getPackage()?.getName()));
        }
      }

      String name;
      if (podName != null) {
        name = podName;
      } else {
        try {
          final podClass = getDefinitionByClass(type);
          name = podClass.name;
        } catch (e) {
          name = type.getName();
        }
      }

      return DefaultObjectProvider(name, this, objects);
    }