Skip to main content

Using Firebase Remote Config

Once installed, you can access the firebase_remote_config plugin by importing it in your Dart code:

import 'package:firebase_remote_config/firebase_remote_config.dart';

Before using Firebase Remote Config, you must first have ensured you have initialized FlutterFire.

To create a new Firebase Remote Config instance, call the instance getter on RemoteConfig:

RemoteConfig remoteConfig = RemoteConfig.instance;

By default, this allows you to interact with Firebase Remote Config using the default Firebase App used whilst installing FlutterFire on your platform. If however you'd like to use a secondary Firebase App, use the instanceFor method:

FirebaseApp secondaryApp ='SecondaryApp');
RemoteConfig remoteConfig = RemoteConfig.instanceFor(app: secondaryApp);


Firebase Remote Config default parameters allows your application to startup without the need to make a network call. To set the default parameters call the setDefaults() method on your RemoteConfig instance:

remoteConfig.setDefaults(<String, dynamic>{
'welcome_message': 'this is the default welcome message',
'feat1_enabled': false,

Fetching and activating#

Only when default parameters are no longer sufficient updates to the Remote Config template should be made in the Firebase console or via the Admin SDK. Use the fetchAndActivate() method on your RemoteConfig instance:

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

The fetchAndActivate() combines the operations of the fetch() and activate() methods which can be used separately if needed.

Get/Use parameters#

Whether using default or fetched parameters, you can fetch the parameter values using the available getters:

Text('Welcome ${remoteConfig.getString('welcome_message')}')

Other getters include: getBool(), getInt(), getDouble(), getValue().


Since fetching involves network calls Remote Config allows you to specify how long cached parameters are valid and how long a fetch should wait before timing out. These settings can be specified using the setConfigSettings() method on your RemoteConfig instance:

await remoteConfig.setConfigSettings(RemoteConfigSettings(
fetchTimeout: Duration(seconds: 10),
minimumFetchInterval: Duration(hours: 1),

The above snippet specifies that a fetch will wait up to 10 seconds before timing out and fetch parameters will be cached for a maximum of 1 hour before being considered stale and going to the server on the next fetch() call.