activate static method
Fetch + activate Remote Config with sensible defaults.
• minimumFetchInterval — Firebase throttle. 1h is fine for most apps;
shorten during a roll-out and re-tighten before release.
• fetchTimeout — how long to wait before falling back to defaults.
• defaults — local fallback values when no fetched value exists for
a key. Same shape Firebase RC accepts (String/num/bool).
Safe to call multiple times — subsequent calls re-fetch + re-activate.
Implementation
static Future<void> activate({
Map<String, dynamic> defaults = const {},
Duration minimumFetchInterval = const Duration(hours: 1),
Duration fetchTimeout = const Duration(seconds: 10),
}) async {
final rc = _rc ??= FirebaseRemoteConfig.instance;
await rc.setConfigSettings(RemoteConfigSettings(
fetchTimeout: fetchTimeout,
minimumFetchInterval: minimumFetchInterval,
));
if (defaults.isNotEmpty) {
await rc.setDefaults(defaults);
}
try {
await rc.fetchAndActivate();
} catch (_) {
// Network down / quota exhausted — defaults still apply, just no fresh
// values. Don't throw to the host app; let it use whatever was cached.
}
_activated = true;
}