diff --git a/lib/data/remote_config_service.dart b/lib/data/remote_config_service.dart index 9fc83fc..ae62272 100644 --- a/lib/data/remote_config_service.dart +++ b/lib/data/remote_config_service.dart @@ -24,7 +24,6 @@ class RemoteConfigService { await remoteConfig.setDefaults(featuresDefaultValues.map((key, value) => MapEntry(key.name, value))); await remoteConfig.activate(); await remoteConfig.ensureInitialized(); - unawaited(remoteConfig.fetch()); log('Firebase remote config initialized successfully'); } on FirebaseException catch (e) { @@ -34,6 +33,8 @@ class RemoteConfigService { } } + Future fetchConfig() => FirebaseRemoteConfig.instance.fetch(); + dynamic getValue(Feature feature) => FirebaseRemoteConfig.instance.getValue(feature.name).toValue(feature); Map getAll() { diff --git a/lib/providers/remote_config_provider.dart b/lib/providers/remote_config_provider.dart index a3fa523..695d3c1 100644 --- a/lib/providers/remote_config_provider.dart +++ b/lib/providers/remote_config_provider.dart @@ -26,6 +26,8 @@ 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()); _updatesSubscription = widget.remoteConfigService.onConfigUpdated().listen( _updateFeatures, onError: (e) => log(e.toString()),