Updated 28 April 2023
Before starting our Blog topic Remote Config In Flutter With Firebase, we will first understand what is Remote Config & How it can be beneficial for our app development.
We can use Remote Config to define parameters in our application and update their values using the cloud.
For example, if we want to change the theme color of the application, then we can change it using Remote config without changing the theme color in the app. We are using Firebase as our Cloud server for configurations.
For the integration of the Remote Config In Flutter With Firebase, we will follow the mentioned steps:
Read more about Flutter app development from mobikul.
We will use the flutter package to perform the operations, we have used the latest version of this package. You can add any version which meets the requirements mentioned here.
1 2 |
firebase_remote_config: ^3.0.9 firebase_analytics: ^10.1.0 |
We need to create a singleton class for initializing the remote config and set the fetch timeout and intervals at which we want to fetch the data from Firebase Remote Config
1 2 3 4 5 |
final remoteConfig = FirebaseRemoteConfig.instance; await remoteConfig.setConfigSettings(RemoteConfigSettings( fetchTimeout: const Duration(minutes: 1), minimumFetchInterval: const Duration(hours: 1), )); |
We are setting default values here, so if there are no values set on the Config or due to some reason we will not get any values from the Remote backend, then we can set the default values.
1 2 3 4 |
await remoteConfig.setDefaults(<String, dynamic>{ 'test': 'default data', 'test message': 'HELLO REMOTE CONFIG MESSAGE', }); |
Now, we will fetch the data 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 setDefaults()
.
These are the following methods through which we can fetch the data from the Remote config object.
getBool()
getDouble()
getInt()
getString()
For the Remote Config, we need to set the values in the Firebase backend, so we can use them inside our application. Click here for setting the values on the Firebase Remote Config backend.
Reference ScreenShot —> https://prnt.sc/pukl6oeUobJ5
In this blog, we have learned about the implementation of the Remote Config In Flutter With Firebase.
For more information regarding the same, you can check this Reference Link
Thanks for reading!!
If you have more details or questions, you can reply to the received confirmation email.
Back to Home
Be the first to comment.