VSCode provides a simple way to create and run your custom Flutter configurations. We could add configurations for the default Flutter run builds for debug, profile and release, but imagine having different product flavors like a free and a pro version.
A thing you should know
In this example there are already different product flavors in your Flutter project, more info about flavor builds on flutter.dev. In this article there will be two product flavors a free and a pro version of an application. In this example app there are two main files: main.dart and main_pro.dart. These are optional, it depends if the pro version of the app uses e.g. another main widget.
Ready, set and 🏃
- Open your Flutter project in VSCode and create (if not made already) a
launch.jsonfile in the
This file will contain our Flutter configuration for VSCode.
- The configuration is a json object so start by creating a json object with the required fields
- In the first Flutter configuration we will define the free version of the app.
Add an object with the following properties:
name(will be displayed in VSCode as configuration name),
type, and last
args(will use the flavor flag in
- As last we will add the pro version in our configurations, it is simular to the free configuration, the only difference is that the
programargument is added, this will specify which
mainfile flutter should use to build.
✅ The result
It’s simple as that. Open the debug panel in VSCode (ctrl + shift + D).
Enjoy your custom Flutter configurations in the top bar. You can select one and it will run that configuration on your attached device or emulator.
I hope this article was helpful, if it is not working like it should, don’t hesitate to contact me and I’ll try to help.
If you happy and you know it 👏 your hands!
Did I make some mistakes or typos? Comment down below and I’ll fix them!