Support envFile in launch configuration
See original GitHub issueIs your feature request related to a problem? Please describe. My project uses a shared launch.json to facilitate development. When launching to an emulator, this is perfect. But when using a real device, I need to point my project to my local ip. Currently the way we do this is by editing the dart-define in our launch.json, then removing the edits before pushing to version control.
Describe the solution you’d like
I’d like to be able to set an env like LOCAL_IP
and reference that in a shared launch configuration. Currently the only way I can see to do this is by setting LOCAL_IP
as an env
in my launch config, which defeats the purpose. There are a few ways to attack this but the most straightforward seems to be supporting envFile
.
Describe alternatives you’ve considered I have looked to see if VS Code supports user-specific launch configs (not ideal but would be fine as our configs rarely change) but I don’t think that they do. In theory you should have access to environment variables within the launch config but in practice this doesn’t seem to be the case.
Additional context Example launch config:
{
"name": "Flutter: Launch Main App (android)",
"request": "launch",
"type": "dart",
"program": "lib/main.dart",
"args": [
"--dart-define=my.api=http://10.0.2.2:5378/api"
]
}
Issue Analytics
- State:
- Created 3 years ago
- Reactions:9
- Comments:22 (11 by maintainers)
Top GitHub Comments
FWIW in #4260 I was told about https://github.com/flutter/flutter/pull/108098 which adds support for reading dart-defines from a file. I don’t think it’s shipped in a stable Flutter yet, but when it does I suspect this will handle many of the use cases above without the need of an additional package.
@DanTup Yes. I can add environment variables to
launch.json
and git ignore it. But I would like to keeplaunch.json
on git and only hide environment variables. For example my current configuration example isThe problem here is that my client environment variables are exposed. Which are different for teammates. Better solution would be provide envFile like in node.js app and use those variables on launch.json
dev.env
With this setup
dev.env
could be git ignored. Another plus point for this is that we can use this same env file for other app for example if we using different tools for web development (react, vuejs)