getProvider<T> method

  1. @override
Future<ObjectProvider<T>> getProvider<T>(
  1. Class<T> type, {
  2. String? podName,
  3. bool allowEagerInit = false,
})

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 f = getPodFactory();

  if (_parent != null) {
    return await _parent!.getProvider(type, podName: podName, allowEagerInit: allowEagerInit);
  }

  return await f.getProvider(type, podName: podName, allowEagerInit: allowEagerInit);
}