Flutter: different app icon and app name depending on release/production build or debug/development build?

Issue

Is there any way of changing the app’s name and/or the app’s icon depending on the building mode selected (development or production) ?

release mode -> Logo A & <app_name>
debug mode -> Logo B & <app_name>-dev

I’ve been looking but could’t find anything —or didn’t search at the right place. Can anyone help ?

Solution

Eventually, I used a flutter feature called flavors which works for Android and iOS.

Here is the guide I followed : https://youtu.be/Vhm1Cv2uPko

For devs using VS Code, I created a VS Code config file to make launching the apps in the different flavors easier :

{
    "version": "0.2.0",
    "configurations": [
        {
            "name": "Launch Development",
            "request": "launch",
            "type": "dart",
            "program": "lib/main_dev.dart",
            "args" : ["--flavor", "development", "--target", "lib/main_dev.dart"],
            // ? Keep flutterMode
            "flutterMode": "debug",
        },
        {
            "name": "Launch Production",
            "request": "launch",
            "type": "dart",
            "program": "lib/main_prod.dart",
            "args": ["--flavor", "production", "--target", "lib/main_prod.dart"],
            // ? Keep flutterMode
            "flutterMode": "release",
        },
        {
            "name": "Run All Tests",
            "type": "dart",
            "request": "launch",
            "program": "./test/",
        },
    ]
}

This subject is treated in the video linked.

Answered By – Rymfire

Answer Checked By – Pedro (FlutterFixes Volunteer)

Leave a Reply

Your email address will not be published.