getObject method

  1. @override
Future<Object> getObject(
  1. Class<Object> type, [
  2. List<ArgumentValue>? args
])

Retrieves a pod as a generic Object by its type with optional arguments.

Similar to getNamedObject but uses type-based lookup instead of name-based.

Usage Example:

final pod = await factory.getObject(Class<DataProcessor>());
if (pod is DataProcessor) {
  pod.processData();
}

@param type The class type of the pod to retrieve @param args Optional list of argument values for pod construction @return A Future that completes with the pod instance as Object

Implementation

@override
Future<Object> getObject(Class<Object> type, [List<ArgumentValue>? args]) async {
  final f = getPodFactory();

  if (await _hasLocalPodsOfType(type)) {
    return await f.getObject(type, args);
  }

  if (_parent != null) {
    return await _parent!.getObject(type, args);
  }

  throw NoSuchPodDefinitionException.byTypeWithMessage(type, 'No object of type $type');
}