flutter run accepts --flavor for Android product flavors and Xcode schemes. If you're using one of the aforementioned, debugging will fail with the following error (Android):
The Gradle project does not define a task suitable for the requested build.
The android/app/build.gradle file defines product flavors: <list of flavor options>
You must specify a --flavor option to select one of them.
For context, this is the flag description:
--flavor Build a custom app flavor as defined by platform-specific build setup.
Supports the use of product flavors in Android Gradle scripts.
Supports the use of custom Xcode schemes.
I'm unfamiliar with this functionality - is there a sample app anywhere that uses it I can use to repro and test the change? Or is it simple for me to modify one of the projects? (@devoncarew)
I don't have a sample project for this myself; @lukef may?
Here's how we expose it in IntelliJ:

It's a free-form text field; if there's something in there, then we pass --flavor=xxx in via flutter run, else we don't pass the flag. Since these are defined in gradle (or ios) files, we don't try and to any validation of the flavor param client side.
Sounds simple enough; though I'd prefer if I could confirm it definitely works before shipping and announcing it's supported. We do have some other options that are more generic (pubAdditionalArgs?), so we could also do something like that and allow you to put whatever you want in (this would be useful if people might extend this with their own switches, though since flutter run --help explicitly lists flavor I guess this is a well-known thing and not user-defined).
Will aim to do this in v2.9; seems simple and sounds like it could stop people being able to use F5.
Ok, I think maybe the existing args already supports this. I just set my launch.json like this:
{
"name": "Flutter",
"request": "launch",
"type": "flutter",
"args": [
"--flavor",
"red"
]
}
When I hit F5, I get this in the debug console:
The Gradle project does not define a task suitable for the requested build.
The android/app/build.gradle file does not define any custom product flavors.
You cannot use the --flavor option.
So, I don't think we need to do anything here. We could add an additional flavor setting, but I don't know how much value there is in it. Any opinions?
Using the existing args sgtm. Perhaps there are some 'using dart-code' docs we could update?
Does VS Code have any provision to do this on a project basis? I know it wont be a fail for apps that don't need it but it could be a problem if you use flavors and work on multiple projects. Its probably a separate issue but just throwing it out there. It's not a big deal, btw, but could be a possible blocker.
@devoncarew
Perhaps there are some 'using dart-code' docs we could update?
Not currently; though I'd really like to address this soon. Even the readme is rather lacking (in terms of helping a new user get started). Maybe this would fit nice on a FAQ page?
@lukef
Does VS Code have any provision to do this on a project basis?
Yep, the snippet I posted is from the .vscode\launch.json file which lives inside your project (FWIW, it actually is a fail for apps that don't need it - fails with a similar message!).
Let me know if you can't get it working (there's a Gitter chat that might be easier for troubleshooting).
I've opened #557 about better docs/faq so gonna WontFix this. If anyone disagrees, shout!
This article helped me solve the problem of build variants. https://cogitas.net/creating-flavors-of-a-flutter-app/
I was stuck for a bit because Flutter isn't very specific about Gradle build errors. The build error I received was Gradle task assembleDebug failed with exit code 1.
The problem is that I was not adding the build variants to Flutter/build.gradle AND app/build.gradle.
The build variants need to be added to both to work correctly.
@DanTup , please need this bug fixed. some projects do require debugging in multi-flavor apps.
@krupalbhardiya as far as I can tell, there is no bug here - you can use flavours by specifying them in the launch config args property (see https://github.com/Dart-Code/Dart-Code/issues/535#issuecomment-364886303) and maybe to Gradle (see the comment before yours above - though I don't think this bit is VS Code-specific). If you're having problems, please open a new issue with specific details of what's happening. Thanks!
Most helpful comment
Ok, I think maybe the existing
argsalready supports this. I just set mylaunch.jsonlike this:When I hit F5, I get this in the debug console:
So, I don't think we need to do anything here. We could add an additional
flavorsetting, but I don't know how much value there is in it. Any opinions?