Skip to content

Commit

Permalink
Merge pull request flutter#28 from collinjackson/flutter#1966
Browse files Browse the repository at this point in the history
[firebase_remote_config] Fix Future already completed RemoteConfig.instance
  • Loading branch information
kroikie authored Aug 30, 2019
2 parents 30359c7 + e21316b commit 08dad0c
Show file tree
Hide file tree
Showing 3 changed files with 9 additions and 4 deletions.
5 changes: 5 additions & 0 deletions packages/firebase_remote_config/CHANGELOG.md
Original file line number Diff line number Diff line change
@@ -1,3 +1,8 @@
## 0.2.0+7

* Fix `Bad state: Future already completed` error when initially
calling `RemoteConfig.instance` multiple times in parallel.

## 0.2.0+6

* Update documentation to reflect new repository location.
Expand Down
6 changes: 3 additions & 3 deletions packages/firebase_remote_config/lib/src/remote_config.dart
Original file line number Diff line number Diff line change
Expand Up @@ -33,12 +33,12 @@ class RemoteConfig extends ChangeNotifier {
/// Gets the instance of RemoteConfig for the default Firebase app.
static Future<RemoteConfig> get instance async {
if (!_instanceCompleter.isCompleted) {
_getRemoteConfigInstance();
_instanceCompleter.complete(await _getRemoteConfigInstance());
}
return _instanceCompleter.future;
}

static void _getRemoteConfigInstance() async {
static Future<RemoteConfig> _getRemoteConfigInstance() async {
final Map<String, dynamic> properties =
await channel.invokeMapMethod<String, dynamic>('RemoteConfig#instance');

Expand All @@ -53,7 +53,7 @@ class RemoteConfig extends ChangeNotifier {
instance._remoteConfigSettings = remoteConfigSettings;
instance._parameters =
_parseRemoteConfigParameters(parameters: properties['parameters']);
_instanceCompleter.complete(instance);
return instance;
}

static Map<String, RemoteConfigValue> _parseRemoteConfigParameters(
Expand Down
2 changes: 1 addition & 1 deletion packages/firebase_remote_config/pubspec.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@ description: Flutter plugin for Firebase Remote Config. Update your application
re-releasing.
author: Flutter Team <flutter-dev@googlegroups.com>
homepage: https://github.com/FirebaseExtended/flutterfire/tree/master/packages/firebase_remote_config
version: 0.2.0+6
version: 0.2.0+7

dependencies:
flutter:
Expand Down

0 comments on commit 08dad0c

Please sign in to comment.