Skip to content

Instantly share code, notes, and snippets.

@ddikman
Created August 16, 2021 12:09
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save ddikman/388bd6a2c586ae1821bb2b46d7f9dfae to your computer and use it in GitHub Desktop.
Save ddikman/388bd6a2c586ae1821bb2b46d7f9dfae to your computer and use it in GitHub Desktop.
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