Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Flutter: add flavors configuration into Visual Studio

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

like image 723
Andrea Miotto Avatar asked Jul 03 '19 13:07

Andrea Miotto


3 Answers

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"
    ]
}
like image 124
Danny Tuppeny Avatar answered Sep 17 '22 01:09

Danny Tuppeny


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" 
            ]
},
like image 45
BIS Tech Avatar answered Sep 18 '22 01:09

BIS Tech


{
  "name": "App Dev",
  "cwd": ".",
  "request": "launch",
  "type": "dart",
  "flutterMode": "debug",
  "program": "lib/main_dev.dart",
  "args": ["--flavor", "dev"],
}
like image 33
Mrr Hak Avatar answered Sep 20 '22 01:09

Mrr Hak