diff --git a/lib/data/remote_config_service.dart b/lib/data/remote_config_service.dart index ae62272..8243dd2 100644 --- a/lib/data/remote_config_service.dart +++ b/lib/data/remote_config_service.dart @@ -33,7 +33,11 @@ class RemoteConfigService { } } - Future fetchConfig() => FirebaseRemoteConfig.instance.fetch(); + Future fetchConfig() async { + // https://github.com/firebase/flutterfire/issues/6196#issuecomment-927751667 + await Future.delayed(const Duration(seconds: 1)); + await FirebaseRemoteConfig.instance.fetch(); + } dynamic getValue(Feature feature) => FirebaseRemoteConfig.instance.getValue(feature.name).toValue(feature); diff --git a/lib/providers/remote_config_provider.dart b/lib/providers/remote_config_provider.dart index 695d3c1..a00b385 100644 --- a/lib/providers/remote_config_provider.dart +++ b/lib/providers/remote_config_provider.dart @@ -26,8 +26,7 @@ class RemoteConfigProviderState extends State { @override void initState() { super.initState(); - // https://github.com/firebase/flutterfire/issues/6196#issuecomment-927751667 - Future.delayed(const Duration(seconds: 1)).then((_) => widget.remoteConfigService.fetchConfig()); + widget.remoteConfigService.fetchConfig(); _updatesSubscription = widget.remoteConfigService.onConfigUpdated().listen( _updateFeatures, onError: (e) => log(e.toString()), diff --git a/test/providers/remote_config_provider_test.dart b/test/providers/remote_config_provider_test.dart index aa6815d..a215cbe 100644 --- a/test/providers/remote_config_provider_test.dart +++ b/test/providers/remote_config_provider_test.dart @@ -18,6 +18,7 @@ void main() { }); setUp(() { + when(() => mockRemoteConfigService.fetchConfig()).thenAnswer((_) async {}); when(() => mockRemoteConfigService.getValue(Feature.unlockProFeaturesText)).thenReturn(false); when(() => mockRemoteConfigService.getAll()).thenReturn({Feature.unlockProFeaturesText: false}); });