Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

[firebase_remote_config] Fix Future already completed RemoteConfig.instance #28

Merged
merged 4 commits into from
Aug 30, 2019
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
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 <[email protected]>
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