Flutter: add flavors configuration into Visual Studio

3,830

Solution 1

You can pass additional arguments using a launch.json. If you don't already have one, click the Cog icon in the Debug sidebar and then select Flutter in the snippet-completion list. You can then add an args section, like this:

{
    "name": "Flutter",
    "request": "launch",
    "type": "flutter",
    "args": [
        "--flavor",
        "app1"
    ]
}

Solution 2

You have to edit your launch.json file

{
            "name": "dev", // you can add nickname for it
            "request": "launch",
            "type": "dart",
            "args": [
                "--flavor", //flavor name
                "dev",
                "-t", // if your have different main file
                "lib/main_dev.dart" 
            ]
},
Share:
3,830
Andrea Miotto
Author by

Andrea Miotto

In love with iOS developing.

Updated on December 12, 2022

Comments

  • Andrea Miotto
    Andrea Miotto over 1 year

    My flutter application has different flavors. In Android Studio everything is setup in the flavor configuration panel, but where can I do that in Visual Studio Code?

    I guess I have to edit the configuration.json but I cant find any reference online on how to do it.

    I do not want every time to type flutter run --flavor app1 -t lib/main_app1.dart

  • Andrea Miotto
    Andrea Miotto almost 5 years
    what do you mean with: "--flavor", "red"
  • Danny Tuppeny
    Danny Tuppeny almost 5 years
    It was just an example of a flavor name - you could put app1 here based on your example (I edited my code to make it clearer).
  • apieceofcode1801
    apieceofcode1801 about 2 years
    @AndreaMiotto it should be marked accepted answer :D