The easiest way to build flavors in Flutter (Android & iOS)


My application will have two different flavors , `UAT` and `Production`, and each flavor will have some different settings, for example

  1. bundle ld
  2. app name
  3. icon
  4. base url

We will set up our apps together according to the following table

Setting different flavor needs to be set independently for different platform(Android & iOS), which is not an easy job you need to have a certain understanding of iOS and Android native development.

Until I found this library, it can help people easily create flavors in the flutter application

Getting Started

  1. Save app icon to flutter assets folder

2. flutter_flavorizr is intended to support development of Dart projects. In general, put it under dev_dependencies, in your pubspec.yaml

3. Create custom flavors based on the table above.
flutter_flavorizr supports many customization settings, please see this link for details.

flutter_flavorizr default processors set is this, if you want skip or only run single processors, you can custom processors set see this


When you finished defining the flavorizr configuration, you can proceed by running the script with:

flutter pub run flutter_flavorizr
// or only run custom set of processors
flutter pub run flutter_flavorizr -p ide:config

flutter_flavorizr will generate a lot of files for different platforms (Android & iOS) based on your pubspec.yaml config

Now it works fine

# production flavor
flutter run --flavor production -t lib/main_production.dart
# uat flavor
flutter run --flavor uat -t lib/main_uat.dart


I found some files are redundant, so you can delete them yourself

  1. [iOS] CFBundleDisplayName is not replaced by $(BUNDLE_NAME) variable

2. [iOS] Delete the following files that are not useful

3. [iOS] Delete the {env}LaunchScreen generated by flutter_flavorizr default

4. [iOS] Delete unused Assets

5. rename flavors.dart to env_config.dartand add baseUrl


Source code:

Other good articles

I hope you enjoy reading this article and hitting clap 👏 .



Get the Medium app

A button that says 'Download on the App Store', and if clicked it will lead you to the iOS App store
A button that says 'Get it on, Google Play', and if clicked it will lead you to the Google Play store