Skip to content

Instantly share code, notes, and snippets.

Embed
What would you like to do?
Example of loading remote config, avoiding stale values during testing
_initRemoteConfig(ExperimentalMode experimentalMode) async {
final RemoteConfig remoteConfig = RemoteConfig.instance;
var cacheDuration = Duration(hours: 1);
// allows us to force update the cache even when we exit the experimental mode
if (experimentalMode.isExperimentalMode || experimentalMode.isConfigStale()) {
cacheDuration = Duration(seconds: 0);
}
experimentalMode.setConfigStale(false);
await remoteConfig.setConfigSettings(RemoteConfigSettings(
fetchTimeout: const Duration(seconds: 10),
minimumFetchInterval: cacheDuration,
));
await remoteConfig.fetchAndActivate();
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment