This page is archived and might not reflect the latest version of the FlutterFire plugins. You can find the latest information on firebase.google.com:
You can use Firebase Remote Config to define parameters in your app and update their values in the cloud, allowing you to modify the appearance and behavior of your app without distributing an app update. This guide walks you through the steps to get started and provides some sample code.
Install and initialize the Firebase SDKs for Flutter if you haven't already done so.
From the root directory of your Flutter project, run the following command to install the Remote Config plugin:flutter pub add firebase_remote_config
Also, as part of setting up Remote Config, you need to add the Firebase SDK for Google Analytics to your app:flutter pub add firebase_analytics
Rebuild your project:flutter run
Because the Remote Config SDK has a dependency on the Remote Config REST API, make sure that you do not disable that API, which is enabled by default in a typical project.
Get a Remote Config object instance and set the minimum fetch interval to allow for frequent refreshes:
The singleton object is used to store in-app default parameter values, fetch updated parameter values from the backend, and control when fetched values are made available to your app.
During development, it's recommended to set a relatively low minimum fetch interval. See Throttling for more information.
You can set in-app default parameter values in the Remote Config object, so that your app behaves as intended before it connects to the Remote Config backend, and so that default values are available if none are set in the backend.
Now you can get parameter values from the Remote Config object. If you set
values in the backend, fetch them, and then activate them,
those values are available to your app. Otherwise, you get the in-app
parameter values configured using
To get these values, call the method listed below that maps to the data type expected by your app, providing the parameter key as an argument:
Using the Firebase console or the Remote Config backend APIs, you can create new server-side default values that override the in-app values according to your desired conditional logic or user targeting. This section describes the Firebase console steps to create these values.
- In the Firebase console, open your project.
- Select Remote Config from the menu to view the Remote Config dashboard.
- Define parameters with the same names as the parameters that you defined in your app. For each parameter, you can set a default value (which will eventually override the corresponding in-app default value), and you can also set conditional values. To learn more, see Remote Config Parameters and Conditions.
To fetch parameter values from the Remote Config backend, call the
fetch()method. Any values that you set in the backend are fetched and stored in the Remote Config object.
To make fetched parameter values available to your app, call the
For cases where you want to fetch and activate values in one call, you can use a
fetchAndActivate()request to fetch values from the Remote Config backend and make them available to the app:await remoteConfig.fetchAndActivate();
Because these updated parameter values affect the behavior and appearance of your app, you should activate the fetched values at a time that ensures a smooth experience for your user, such as the next time that the user opens your app. See Remote Config loading strategies for more information and examples.
If an app fetches too many times in a short time period, fetch calls will be
throttled and the value of
property will be
The default minimum fetch interval for Remote Config is 12 hours, which means that configs won't be fetched from the backend more than once in a 12 hour window, regardless of how many fetch calls are actually made.
During app development, you might want to fetch and activate configs very frequently
(many times per hour) to let you rapidly iterate as you develop and test your
app. To accommodate rapid iteration on a project with up to 10 developers, you
can temporarily set a low minimum fetch interval with
Keep in mind that this setting should be used for development only, not for an app running in production. If you're just testing your app with a small 10-person development team, you are unlikely to hit the hourly service-side quota limits. But if you pushed your app out to thousands of test users with a very low minimum fetch interval, your app would probably hit this quota.
If you haven't already, explore the Remote Config use cases, and take a look at some of the key concepts and advanced strategies documentation, including: