If you read my last Flutter story you know that we had a problem configuring flavors in Flutter.

Why to use flavors

Working alone as a hobbyist android developer I never looked at flavors/build-config.

I did not need them, I was the only person of my team and the only stakeholder ¯\(ツ)/¯

Here at Iakta the team is bigger and we have many customers, so if something goes wrong you cannot just yell at the mirror.

Me angry with me

Flavors are just comfortable. They let you define some build configuration and switch them as you want. For example you could have one flavor for development, and one for production. You can set different url for api calls or different icons and app names. With a click you’re ready to develop or to release your great application.

We use a lot flavor configurations, not only for comfort, but also to be sure to deploy the right version of the app. We just set different icons and sometimes even app theme to be sure not to release an app with an api url pointing to local or staging machines. That would be very dangerous and shameful.

Me ashamed

Usually we use from 3 to 5 different flavor per app (development, production, staging, demo..)

Flavors in Flutter

When it comes to Flutter, flavors are easy to implement, but if you don’t know android flavors and iOS schema you can have some problem. I used to use android buildConfigs and iOS targets and so it was not so straightforward.

Flutter cli has an option for flavors, so you can run/build your app using flavors:

flutter build --flavor development

These are mapped to android productFlavors and iOS schema.

Android productFlavors

Regarding android the productFlavors are defined in the app gradle module.