get<T> method

T? get<T>()

Attempts to synchronously resolve a service of type T from the container.

Returns null if the service is not available, cannot be resolved synchronously, or if any error occurs during resolution.

// Inside a DriverConfigBuilder:
final StorageDefaults? defaults = context.get<StorageDefaults>();
if (defaults != null) {
  // Use storage defaults
}

Implementation

T? get<T>() {
  if (!container.has<T>()) {
    return null;
  }
  try {
    return container.get<T>();
  } catch (_) {
    return null;
  }
}