Vicboy
    • Create new note
    • Create a note from template
      • Sharing URL Link copied
      • /edit
      • View mode
        • Edit mode
        • View mode
        • Book mode
        • Slide mode
        Edit mode View mode Book mode Slide mode
      • Customize slides
      • Note Permission
      • Read
        • Only me
        • Signed-in users
        • Everyone
        Only me Signed-in users Everyone
      • Write
        • Only me
        • Signed-in users
        • Everyone
        Only me Signed-in users Everyone
      • Engagement control Commenting, Suggest edit, Emoji Reply
      • Invitee
    • Publish Note

      Share your work with the world Congratulations! 🎉 Your note is out in the world Publish Note

      Your note will be visible on your profile and discoverable by anyone.
      Your note is now live.
      This note is visible on your profile and discoverable online.
      Everyone on the web can find and read all notes of this public team.
      See published notes
      Unpublish note
      Please check the box to agree to the Community Guidelines.
      View profile
    • Commenting
      Permission
      Disabled Forbidden Owners Signed-in users Everyone
    • Enable
    • Permission
      • Forbidden
      • Owners
      • Signed-in users
      • Everyone
    • Suggest edit
      Permission
      Disabled Forbidden Owners Signed-in users Everyone
    • Enable
    • Permission
      • Forbidden
      • Owners
      • Signed-in users
    • Emoji Reply
    • Enable
    • Versions and GitHub Sync
    • Note settings
    • Engagement control
    • Transfer ownership
    • Delete this note
    • Save as template
    • Insert from template
    • Import from
      • Dropbox
      • Google Drive
      • Gist
      • Clipboard
    • Export to
      • Dropbox
      • Google Drive
      • Gist
    • Download
      • Markdown
      • HTML
      • Raw HTML
Menu Note settings Sharing URL Create Help
Create Create new note Create a note from template
Menu
Options
Versions and GitHub Sync Engagement control Transfer ownership Delete this note
Import from
Dropbox Google Drive Gist Clipboard
Export to
Dropbox Google Drive Gist
Download
Markdown HTML Raw HTML
Back
Sharing URL Link copied
/edit
View mode
  • Edit mode
  • View mode
  • Book mode
  • Slide mode
Edit mode View mode Book mode Slide mode
Customize slides
Note Permission
Read
Only me
  • Only me
  • Signed-in users
  • Everyone
Only me Signed-in users Everyone
Write
Only me
  • Only me
  • Signed-in users
  • Everyone
Only me Signed-in users Everyone
Engagement control Commenting, Suggest edit, Emoji Reply
Invitee
Publish Note

Share your work with the world Congratulations! 🎉 Your note is out in the world Publish Note

Your note will be visible on your profile and discoverable by anyone.
Your note is now live.
This note is visible on your profile and discoverable online.
Everyone on the web can find and read all notes of this public team.
See published notes
Unpublish note
Please check the box to agree to the Community Guidelines.
View profile
Engagement control
Commenting
Permission
Disabled Forbidden Owners Signed-in users Everyone
Enable
Permission
  • Forbidden
  • Owners
  • Signed-in users
  • Everyone
Suggest edit
Permission
Disabled Forbidden Owners Signed-in users Everyone
Enable
Permission
  • Forbidden
  • Owners
  • Signed-in users
Emoji Reply
Enable
Import from Dropbox Google Drive Gist Clipboard
   owned this note    owned this note      
Published Linked with GitHub
Subscribed
  • Any changes
    Be notified of any changes
  • Mention me
    Be notified of mention me
  • Unsubscribe
Subscribe
# How to Customize your Flutter App features Using Firebase Remote Config # Introduction [Flutter](https://flutter.dev/) is a popular open-source framework for building cross-platform mobile applications. It enables developers to create visually appealing and feature-rich apps that run smoothly on both iOS and Android. However, as apps grow in complexity, there's often a need to customize features on the fly without having to go through the entire development process. This is where Firebase Remote Config comes into play. It’s a stressful and time-consuming process updating a mobile application that is already out in production, having to go through the uploading process, and also waiting for your app to be reviewed before updates are released. Firebase Remote Config makes it easier to change the behavior and appearance of our app without necessarily rolling out a new release for users to download. In this article, we will explore how Firebase Remote Config can be used to customize your Flutter app's features, giving you the ability to update app configurations and settings in real-time. Whether you're a beginner or an experienced Flutter developer, this guide will provide you with the tools and knowledge you need to take your app to the next level. ## What is Firebase Remote Config. Firebase Remote Config is a cloud-based service provided by Google's Firebase platform that allows developers to dynamically change the behavior and appearance of their mobile applications without having to release a new app version. With Firebase Remote Config, developers can define and update app configuration values, such as text strings, themes, and feature flags, in real-time from a remote server. These values can then be fetched and applied within the app at runtime, enabling developers to make instant changes to their apps without having to go through the time-consuming and stressful process of updating the app in production. Firebase Remote Config is especially useful for A/B testing, enabling developers to test new features with a subset of users before rolling them out to the entire user base. This way, developers can get feedback on new features and make data-driven decisions about which changes to keep and which to discard. Overall, Firebase Remote Config is a powerful tool that helps Flutter developers streamline the app development process, allowing them to quickly and easily customize their apps and deliver new features and improvements in real-time. ## Prerequisite - A [Firebase Console](https://console.firebase.google.com) Account. ## Firebase Remote Config Installation In this tutorial, you can work with your existing flutter application on your can create a new flutter app by following [flutter documentation](https://docs.flutter.dev/get-started/install). Before installing firebase remote, you will need to [add firebase to your flutter application](http://firebase.google.com/docs/flutter/setup?platform=ios). After which you can procced with the few steps below. - Add the firebase remote config plugin by running the command below from the root directory of your flutter project: ```jsx flutter pub add firebase_remote_config ``` - Adding the Firebase SDK for Google Analytics will also be needed for your app. You can add this by running the command below: ```jsx flutter pub add firebase_analytics ``` - Start your project: ```jsx flutter run ``` ## Creating Parameter Values. To be able to control your app behaviors remotely, you will need to define parameters and their respective values. To do this, go to your project on [firebase console](http://console.firebase.google.com) dashboad and click the remote config tab which is located in the left drawer, under the build drop-down. ![](https://i.imgur.com/Q75g3AR.jpg) Then click on the create configuration button, this button will bring up a form for you to add parameters this fields may include : - Parameter name( The name used to access the parameter). - Data type (The data type for the parameter). - Description(A breif description about the parameter, this is optional). - Default value(The default value for the parameter). In this case, you be will setting two parameters, **Firstly** for our app’s primary color and **Secondly** to control the behavior of the greeting dialog in your app. Create first parameter ![](https://i.imgur.com/4gOR5vK.png) Edit parameter ![](https://i.imgur.com/erntoTH.png) ## Setting Conditions You can set set conditions for these parameters so that they can have different values depending on specific conditions(which may include platform, languages, country/region, date time, etc). To do this Go to **Add New => Conditional value => Create new condition** Here a dialog will pop up for you to fill in the conditions for this parameter. In this case, you will be setting different values for our parameters depending on the platform (IOS/Android) then click save. Define Conditions ![](https://i.imgur.com/flrSGNo.png) Edit parameters for condition ![](https://i.imgur.com/7k6hqbN.png) Finally click on publish changes to publishes changes to your app. ## Create Firebase Remote Config Service Class Here are steps of how you can create a Firebase Remote Config Service class in Flutter: ### Create Dart class You will create a services folder that will contain a dart class named `RemoteConfigService.dart` ![](https://i.imgur.com/nxHf4B8.png) ### Create helper methods You will create two methods inside our `RemoteConfigService` class. 1. The `_init` method: This will be a private method. Inside here you will create a firebase remote config instance, set configurations for the remote config object, and **Fetch** and **Activate** all remote parameters. Your code should look like this : ``` //FLUTTER _init() async { final remoteConfig = FirebaseRemoteConfig.instance; await remoteConfig .setConfigSettings(RemoteConfigSettings( fetchTimeout: const Duration(microseconds: 1), minimumFetchInterval: const Duration(hours: 1), )) .then((value) async { await remoteConfig.fetchAndActivate(); }); } ``` . The `create` method : This method initializes FirebaseRemoteConfig by calling the `_init` method. Now the `RemoteConfigService.dart` ****the class should look like the code block below: ``` //FLUTTER class RemoteConfigsService { RemoteConfigsService._(); /// [RemoteConfigsService] factory constructor. static Future<RemoteConfigsService> create() async { final RemoteConfigsService remoteConfigsService = RemoteConfigsService._(); await remoteConfigsService._init(); return remoteConfigsService; } _init() async { final remoteConfig = FirebaseRemoteConfig.instance; await remoteConfig .setConfigSettings(RemoteConfigSettings( fetchTimeout: const Duration(microseconds: 1), minimumFetchInterval: const Duration(milliseconds: 100), )) .then((value) async { await remoteConfig.fetchAndActivate(); }); } } ``` Here you used the `setConfigSettings()` method to set remote configurations for the current `FirebaseRemoteConfig` instance. ## Integrating into Flutter Project Using Parameters. Now its time to integrate your flutter project to work with your already defined parameters on the firebase console. This tutorial will be working with a greeting app, which will display greetings according to the current time. It will use values from the firebase config to decide if to show these greetings using a dialog or bottom sheet. And it will also use these values to decide the primary color of our app. To do this, start with the following steps: 1. Create a `RemoteConfigKeys.dart` class, this class will contain all our parameter keys: ``` // DART class RemoteConfigKeys{ static const String primaryColor = 'primary_color'; static const String showDialog = 'show_dialog'; } ``` 2. Initialize your firebase app and call the `create` method defined in the `RemoteConfigsService` class, in the `main.dart` file before the app runs: ``` //FLUTTER void main() async { WidgetsFlutterBinding.ensureInitialized(); await Firebase.initializeApp(); await RemoteConfigsService.create(); runApp( MyApp()); } ``` The above code will initialize a Firebase app , configure Firebase Remote Config and also `Fetch` and `Activate` all remote parameters. . Get the `primary_color` parameter value and use it as your app’s primary color. ``` //FLUTTER class MyApp extends StatelessWidget { MyApp({super.key}); FirebaseRemoteConfig firebaseRemoteConfig = FirebaseRemoteConfig.instance; // This widget is the root of your application. @override Widget build(BuildContext context) { return MaterialApp( title: 'Greeting App', theme: ThemeData( primaryColor: HexColor.fromHex(firebaseRemoteConfig.getString(RemoteConfigKeys.primaryColor)), ), home: const HomeScreen(), ); } } ``` In the above code you declared an instance of the `FirebaseRemoteConfig` class which we used to retrieve the primary color value and used it as your app’s primary color. 1. Get the `show_dialog` parameter value in our home screen and use it to switch between showing a dialog or a bottom sheet. The `Homescreen.dart` file should look like this: ``` //FLUTTER class HomeScreen extends StatefulWidget { const HomeScreen({Key? key}) : super(key: key); @override State<HomeScreen> createState() => _HomeScreenState(); } class _HomeScreenState extends State<HomeScreen> { String _greeting = ''; FirebaseRemoteConfig firebaseRemoteConfig = FirebaseRemoteConfig.instance; @override void initState() { super.initState(); _updateGreeting(); //Periodically updating greeting Timer.periodic(const Duration(seconds: 1), (timer) { setState(() { _updateGreeting(); }); }); } // Updating the greeting variable with respect to time void _updateGreeting() { var now = DateTime.now(); if (now.hour < 12) { _greeting = 'Hello Good morning'; } else if (now.hour < 17) { _greeting = ' Hello Good afternoon'; } else { _greeting = 'Good evening'; } } @override Widget build(BuildContext context) { return Scaffold( appBar: AppBar( backgroundColor: Theme.of(context).primaryColor, title: const Text('Greeting App'), ), body: Center( child: Padding( padding: const EdgeInsets.all(16), child: Column( crossAxisAlignment: CrossAxisAlignment.center, mainAxisSize: MainAxisSize.min, children: [ const Text( 'Hello \nWelcome to the greeting App', textAlign: TextAlign.center, style: TextStyle(fontSize: 20, fontWeight: FontWeight.bold), ), const SizedBox( height: 16, ), const Text('Click on the button below to show greeting'), const SizedBox( height: 16, ), ElevatedButton( style: ElevatedButton.styleFrom( backgroundColor: Theme.of(context).primaryColor, ), onPressed: () { // Retreiving the value for the show_dialog parameter and // using its value to decide if to show a dialog of bottomsheet firebaseRemoteConfig.getBool(RemoteConfigKeys.showDialog) ? showDialog( context: context, builder: (context) => Dialog( shape: const RoundedRectangleBorder(), child: SizedBox( height: 200, child: GreetingWidget( greeting: _greeting, ), )), ) : showModalBottomSheet( context: context, constraints: const BoxConstraints(maxHeight: 200), builder: (context) => GreetingWidget(greeting: _greeting)); }, child: const Text('Show greeting')) ], ), ), ), ); } ``` In the above code, you designed your home screen to have an appbar and an elevated button. After which you created an `_updateGreeting()` method which updates a greeting String variable with respect to the current time. Also, you created an instance of `FirebaseRomoteConfig` that was used to retrieve the `show_dialog` boolean parameter. And finally, you used the value of this parameter to determine the behavior of your greeting app either to show greetings using a dialog or a bottom sheet. # ****Testing App**** You can test your app with the command below: ```jsx flutter run ``` ### ANDROID RESULT ![](https://i.imgur.com/qglL5Rp.gif) ### IOS RESULT ![](https://i.imgur.com/b8bG2Ie.gif) Bravos! You have just integrated our app to have different appearance and behavior on `IOS` and `ANDROID` # Conclusion. In conclusion, customizing your Flutter app's features has never been easier, thanks to Firebase Remote Config. This powerful tool allows you to change the behavior and appearance of your app on-the-fly, without the need to re-publish it in the app stores. Whether you want to experiment with different features, target specific groups of users, or simply update your app's look and feel, Firebase Remote Config makes it all possible. With its user-friendly interface, detailed documentation, and seamless integration with Flutter, Firebase Remote Config is an essential tool for any Flutter app developer looking to bring their app to the next level. So if you're ready to take your app to the next level and start customizing its features like never before, get started with Firebase Remote Config today!

Import from clipboard

Paste your markdown or webpage here...

Advanced permission required

Your current role can only read. Ask the system administrator to acquire write and comment permission.

This team is disabled

Sorry, this team is disabled. You can't edit this note.

This note is locked

Sorry, only owner can edit this note.

Reach the limit

Sorry, you've reached the max length this note can be.
Please reduce the content or divide it to more notes, thank you!

Import from Gist

Import from Snippet

or

Export to Snippet

Are you sure?

Do you really want to delete this note?
All users will lose their connection.

Create a note from template

Create a note from template

Oops...
This template has been removed or transferred.
Upgrade
All
  • All
  • Team
No template.

Create a template

Upgrade

Delete template

Do you really want to delete this template?
Turn this template into a regular note and keep its content, versions, and comments.

This page need refresh

You have an incompatible client version.
Refresh to update.
New version available!
See releases notes here
Refresh to enjoy new features.
Your user state has changed.
Refresh to load new user state.

Sign in

Forgot password

or

By clicking below, you agree to our terms of service.

Sign in via Facebook Sign in via Twitter Sign in via GitHub Sign in via Dropbox Sign in with Wallet
Wallet ( )
Connect another wallet

New to HackMD? Sign up

Help

  • English
  • 中文
  • Français
  • Deutsch
  • 日本語
  • Español
  • Català
  • Ελληνικά
  • Português
  • italiano
  • Türkçe
  • Русский
  • Nederlands
  • hrvatski jezik
  • język polski
  • Українська
  • हिन्दी
  • svenska
  • Esperanto
  • dansk

Documents

Help & Tutorial

How to use Book mode

Slide Example

API Docs

Edit in VSCode

Install browser extension

Contacts

Feedback

Discord

Send us email

Resources

Releases

Pricing

Blog

Policy

Terms

Privacy

Cheatsheet

Syntax Example Reference
# Header Header 基本排版
- Unordered List
  • Unordered List
1. Ordered List
  1. Ordered List
- [ ] Todo List
  • Todo List
> Blockquote
Blockquote
**Bold font** Bold font
*Italics font* Italics font
~~Strikethrough~~ Strikethrough
19^th^ 19th
H~2~O H2O
++Inserted text++ Inserted text
==Marked text== Marked text
[link text](https:// "title") Link
![image alt](https:// "title") Image
`Code` Code 在筆記中貼入程式碼
```javascript
var i = 0;
```
var i = 0;
:smile: :smile: Emoji list
{%youtube youtube_id %} Externals
$L^aT_eX$ LaTeX
:::info
This is a alert area.
:::

This is a alert area.

Versions and GitHub Sync
Get Full History Access

  • Edit version name
  • Delete

revision author avatar     named on  

More Less

Note content is identical to the latest version.
Compare
    Choose a version
    No search result
    Version not found
Sign in to link this note to GitHub
Learn more
This note is not linked with GitHub
 

Feedback

Submission failed, please try again

Thanks for your support.

On a scale of 0-10, how likely is it that you would recommend HackMD to your friends, family or business associates?

Please give us some advice and help us improve HackMD.

 

Thanks for your feedback

Remove version name

Do you want to remove this version name and description?

Transfer ownership

Transfer to
    Warning: is a public team. If you transfer note to this team, everyone on the web can find and read this note.

      Link with GitHub

      Please authorize HackMD on GitHub
      • Please sign in to GitHub and install the HackMD app on your GitHub repo.
      • HackMD links with GitHub through a GitHub App. You can choose which repo to install our App.
      Learn more  Sign in to GitHub

      Push the note to GitHub Push to GitHub Pull a file from GitHub

        Authorize again
       

      Choose which file to push to

      Select repo
      Refresh Authorize more repos
      Select branch
      Select file
      Select branch
      Choose version(s) to push
      • Save a new version and push
      • Choose from existing versions
      Include title and tags
      Available push count

      Pull from GitHub

       
      File from GitHub
      File from HackMD

      GitHub Link Settings

      File linked

      Linked by
      File path
      Last synced branch
      Available push count

      Danger Zone

      Unlink
      You will no longer receive notification when GitHub file changes after unlink.

      Syncing

      Push failed

      Push successfully