Set Icon, URL, and App Name Based on App Flavor
Kyaw Soe Win
Experienced Mobile Developer | Android Developer | Mobile Engineer | Specializing in mobile application development | Flutter Developer | Jetpack Compose | Dart | KMP
When we develop applications, we often work with different URLs like dev URL or prod URL. In some cases, there might also be a staging URL.
Personally, I prefer splitting into three categories: dev, staging, and prod.
In Flutter, we can use the flutter_flavorizr package to separate app flavors. For Android, you can customize the applicationId, and for iOS, you can modify the bundleID as you prefer. There are many other options available as well.
The flutter_launcher_icons package is used for App Icons.
With flutter_launcher_icons, based on the flavors defined, you can create a YAML file for each flavor and change the App Icon accordingly: flutter_launcher_icons-<flavor_name>.yaml
For more details, you can check the documentation on pub.dev .
Feel free to point out any mistakes or share in the comments if you know a better way!
Here is sample repo.
Lastly, there’s flutter_dotenv.
I use it when I want to manage things like BASE_URL or toggle features on and off. Sometimes, in development, I want to show everything, but in production, I might not want to display certain things. So, I use a flag for that (P.S. It’s better if you can decide from the beginning whether to include it in prod or not).