Varun
Varun

Reputation: 1968

Flutter: info: 'await' applied to 'RemoteConfig', which is not a 'Future'

I am getting an info message after upgrading my Firebase packages. The documentation wasn't helpful. The line below is triggering the info compiler alert.

RemoteConfig remoteConfig = await RemoteConfig.instance;

The info message is:

info: 'await' applied to 'RemoteConfig', which is not a 'Future'. (await_only_futures at lib/splash.dart:72)

While this is just an 'info' message and doesn't prevent compilation, I want to make sure that I am not doing anything wrong. Please help.

Upvotes: 1

Views: 1461

Answers (1)

Frank van Puffelen
Frank van Puffelen

Reputation: 600120

As the FlutterFire documentation on using Remote Config shows, the call to RemoteConfig.instance is not asynchronous and is:

RemoteConfig remoteConfig = RemoteConfig.instance;

Where you will need to deal with asynchronous behavior is when fetching the remote config, which can be done with:

bool updated = await remoteConfig.fetchAndActivate();
if (updated) {
  // the config has been updated, new parameter values are available.
} else {
  // the config values were previously updated.
}

both snippets are from the linked documentation, so I recommend keeping that page handy.

Upvotes: 3

Related Questions