-
Notifications
You must be signed in to change notification settings - Fork 344
Description
Describe the bug
Running the project from the terminal with the --web-define flag works.
flutter run -d chrome --web-hostname localhost --web-port 43377 --web-define=APP_TITLE=Test
The device, port and other flags work when running the project using launch.json, except the --web-define flag:
I thought VSCode/Cursor could be modifying the arguments, but apparently they're correct:
I checked if the Dart executable was receiving the flags too:
I tried many ways to configure the flag, including separating it in 2 parts ("--web-define" and "APP_TITLE=Test"), moving to "toolArgs" instead of "args" and adding escaped quotation marks.
Edit: for reference, --dart-define works.
To Reproduce
Steps to reproduce the behavior:
- Create a new Flutter project.
- Configure the
launch.jsonfile:
launch.json
{ "version": "0.2.0", "configurations": [ { "name": "Test (Web)", "type": "dart", "request": "launch", "args": [ "-d", "chrome", "--web-hostname", "localhost", "--web-port", "43377", "--web-define=APP_TITLE=Test", ] } ] }- Edit the index.html title tag to
<title>{{APP_TITLE}}</title>. - Run the project.
- Check that the browser URL port is correctly set, but there's an error in the console saying the APP_TITLE variable is missing.
Expected behavior
The --web-define flag should be able to be configured directly in launch.json. Instead of having to run a command in the terminal.
Workspace Environment
Dart Code extension: 3.128.0
Flutter extension: 3.128.0 (activated)
App: Cursor
App Host: desktop
Version: win 1.105.1
Workspace type: Flutter (LSP)
Dart (3.11.0): C:\flutter\bin\cache\dart-sdk
Flutter (3.41.2): C:\flutter (Chrome (web-javascript/web))
Output from 'dart info'
C:\flutter\bin\cache\dart-sdk\bin\dart.exe info
General info
- Dart 3.11.0 (stable) (Mon Feb 9 00:38:07 2026 -0800) on "windows_x64"
- on windows / "Windows 11 Home Single Language" 10.0 (Build 26200)
- locale is pt-BR
Output from 'flutter doctor'
C:\flutter\bin\flutter.bat doctor -v
[√] Flutter (Channel stable, 3.41.2, on Microsoft Windows [versÆo 10.0.26200.7840], locale pt-BR) [316ms]
• Flutter version 3.41.2 on channel stable at C:\flutter
• Upstream repository https://github.com/flutter/flutter.git
• Framework revision 90673a4eef (11 days ago), 2026-02-18 13:54:59 -0800
• Engine revision 6c0baaebf7
• Dart version 3.11.0
• DevTools version 2.54.1
• Feature flags: enable-web, enable-linux-desktop, enable-macos-desktop, enable-windows-desktop, enable-android, enable-ios, cli-animations, enable-native-assets, omit-legacy-version-file, enable-lldb-debugging, enable-uiscene-migration
[√] Windows Version (Windows 11 or higher, 25H2, 2009) [1.300ms]
[X] Android toolchain - develop for Android devices [136ms]
• Android SDK at C:\Users\Wdest\AppData\Local
• Emulator version unknown
X cmdline-tools component is missing.
Try installing or updating Android Studio.
Alternatively, download the tools from https://developer.android.com/studio#command-line-tools-only and make sure to set the ANDROID_HOME environment variable.
See https://developer.android.com/studio/command-line for more details.
[√] Chrome - develop for the web [111ms]
• Chrome at C:\Users\Wdest\AppData\Local\Google\Chrome\Application\chrome.exe
[√] Visual Studio - develop Windows apps (Visual Studio Community 2022 17.14.19) [110ms]
• Visual Studio at C:\Program Files\Microsoft Visual Studio\2022\Community
• Visual Studio Community 2022 version 17.14.36623.8
• Windows 10 SDK version 10.0.26100.0
[√] Connected device (3 available) [133ms]
• Windows (desktop) • windows • windows-x64 • Microsoft Windows [versÆo 10.0.26200.7840]
• Chrome (web) • chrome • web-javascript • Google Chrome 145.0.7632.117
• Edge (web) • edge • web-javascript • Microsoft Edge 145.0.3800.82
[√] Network resources [732ms]
• All expected network resources are available.
! Doctor found issues in 1 category.