getRemoteConfigTyped method

({bool isRemote, Object? value}) getRemoteConfigTyped(
  1. String key,
  2. PrefType type
)

Reads a Remote Config value cast to the given PrefType.

Returns (value: null, isRemote: false) when Firebase is disabled or the key has no remotely-fetched value, so callers can fall through to their own defaults. When a remote value is present it is cast directly off type — no type sniffing, since the caller already knows the type.

Implementation

({Object? value, bool isRemote}) getRemoteConfigTyped(
  String key,
  PrefType type,
) {
  final rc = remoteConfig;
  if (rc == null) return (value: null, isRemote: false);

  final val = rc.getValue(key);
  if (val.source != .valueRemote) return (value: null, isRemote: false);

  final value = switch (type) {
    .boolean => val.asBool(),
    .integer => val.asInt(),
    .double => val.asDouble(),
    .string => val.asString(),
    .stringList => val.asString().split(','),
  };
  return (value: value, isRemote: true);
}