app<T> function

T app<T>([
  1. String? context
])

Resolves a service from the container.

If T is provided, it resolves the service of type T. If no type is provided (dynamic), it returns the ContainerInterface.

Example:

final logger = app<Logger>();
final container = app();

Implementation

T app<T>([String? context]) {
  // If T is dynamic (no type argument provided), return the container
  if (T == dynamic || T == Object) {
    return Khadem.container as T;
  }

  // Otherwise resolve the service
  return Khadem.make<T>(context);
}