From 59d94bf1f142d3604a6949190cf49557bb7f251e Mon Sep 17 00:00:00 2001 From: Vadim <44135514+vodemn@users.noreply.github.com> Date: Tue, 7 Nov 2023 10:56:44 +0100 Subject: [PATCH] internal remote config fetch error --- lib/data/remote_config_service.dart | 3 ++- lib/providers/remote_config_provider.dart | 2 ++ 2 files changed, 4 insertions(+), 1 deletion(-) 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()),