pullSecretsAs<T> method

Future<T> pullSecretsAs<T>(
  1. T fromMap(
    1. Map<String, String>
    ), {
  2. String? projectRef,
  3. String? environmentSlug,
  4. bool fallbackOnError = true,
})

Pulls secrets and maps them to a typed object via fromMap.

Use this together with a generated secrets class:

final secrets = await client.pullSecretsAs(AppSecrets.fromMap);
print(secrets.databaseUrl);

Generate the secrets class with: bella secrets generate dart --types

When fallbackOnError is true (default) and the request fails (e.g. no network), an empty map is returned instead of throwing — safe for mobile.

Implementation

Future<T> pullSecretsAs<T>(
  T Function(Map<String, String>) fromMap, {
  String? projectRef,
  String? environmentSlug,
  bool fallbackOnError = true,
}) async {
  final raw = await pullSecrets(
    projectRef: projectRef,
    environmentSlug: environmentSlug,
    fallbackOnError: fallbackOnError,
  );
  return fromMap(raw);
}