Created
August 16, 2021 12:09
-
-
Save ddikman/388bd6a2c586ae1821bb2b46d7f9dfae to your computer and use it in GitHub Desktop.
Example of loading remote config, avoiding stale values during testing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
_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