Skip to content

--web-define doesn't work with flutter run --machine #183170

@DanTup

Description

@DanTup

Steps to reproduce

  1. Create a new Flutter app
  2. Update the title tag in web/index.html to <title>{{APP_TITLE}}</title>
  3. Run from the terminal with flutter run -d chrome --web-define=APP_TITLE=Test and notice that everything works
  4. Run from the terminal with flutter run --machine -d chrome --web-define=APP_TITLE=Test and notice that it fails with a server error and output in the terminal saying --web-define was missing

Expected results

--web-define should work the same in --machine mode was normal mode. --machine mode is what IDEs use to launch Flutter apps.

Actual results

The app fails to load correctly and errors are printed.

Code sample

N/A

Screenshots or Video

Screenshots / Video demonstration Image

Logs

Logs
[{"event":"daemon.connected","params":{"version":"0.6.1","pid":21996}}]
[{"event":"app.start","params":{"appId":"540b34ab-c5e2-40ac-8289-85bf169fcca1","deviceId":"chrome","directory":"D:\\Dev\\Test Projects\\dartcode_5942","supportsRestart":true,"launchMode":"run","mode":"debug"}}]
Launching lib\main.dart on Chrome in debug mode...
[{"event":"app.progress","params":{"appId":"540b34ab-c5e2-40ac-8289-85bf169fcca1","id":"0","progressId":null,"message":"Waiting for connection from debug service on Chrome...","finished":false}}]
[{"event":"app.progress","params":{"appId":"540b34ab-c5e2-40ac-8289-85bf169fcca1","id":"0","progressId":null,"finished":true}}]
[{"event":"app.webLaunchUrl","params":{"url":"http://localhost:62202","launched":true}}]
[{"event":"app.started","params":{"appId":"540b34ab-c5e2-40ac-8289-85bf169fcca1"}}]
ERROR - 2026-03-03 18:03:13.405199
GET /
Error thrown by handler.
Error: Missing web-define variable: APP_TITLE

Please provide the missing variable using:
flutter run --web-define=APP_TITLE=VALUE
or
flutter build web --web-define=APP_TITLE=VALUE
package:flutter_tools/src/base/common.dart 34:3                  throwToolExit
package:flutter_tools/src/web_template.dart 191:5                WebTemplate._applyVariableSubstitutions
package:flutter_tools/src/web_template.dart 136:18               WebTemplate.withSubstitutions
package:flutter_tools/src/isolated/web_asset_server.dart 651:17  WebAssetServer._serveIndexHtml
package:flutter_tools/src/isolated/web_asset_server.dart 452:14  WebAssetServer.handleRequest
package:flutter_tools/src/isolated/proxy_middleware.dart 56:22   _applyProxyRules
package:flutter_tools/src/isolated/proxy_middleware.dart 63:14   proxyMiddleware.<fn>.<fn>
package:dwds/src/handlers/injector.dart 126:28                   DwdsInjector.middleware.<fn>.<fn>

Flutter Doctor output

Doctor output
[!] Flutter (Channel master, 3.42.0-0.3.pre, on Microsoft Windows [Version 10.0.26200.7840], locale en-GB) [4.7s]
    • Flutter version 3.42.0-0.3.pre on channel master at D:\Dev\Google\Flutter\Flutter main
    ! Upstream repository [email protected]:DanTup/flutter.git is not a standard remote.
      Set environment variable "FLUTTER_GIT_URL" to [email protected]:DanTup/flutter.git to dismiss this error.
    • Framework revision da72d5936d (5 weeks ago), 2026-01-29 03:07:48 +0000
    • Engine revision da72d5936d
    • Dart version 3.12.0 (build 3.12.0-80.0.dev)
    • DevTools version 2.54.0
    • 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,   
      enable-riscv64
    • If those were intentional, you can disregard the above warnings; however it is recommended to use "git" directly to perform update checks and upgrades.

[√] Windows Version (11 Pro 64-bit, 25H2, 2009) [1,080ms]

[!] Android toolchain - develop for Android devices (Android SDK version 35.0.0) [3.8s]
    • Android SDK at C:\Users\danny\AppData\Local\Android\sdk
    • Emulator version 36.3.10.0 (build_id 14472402) (CL:N/A)
    • Platform android-36, build-tools 35.0.0
    • Java binary at: C:\Program Files\Android\Android Studio\jbr\bin\java
      This is the JDK bundled with the latest Android Studio installation on this machine.
      To manually set the JDK path, use: `flutter config --jdk-dir="path/to/jdk"`.
    • Java version OpenJDK Runtime Environment (build 21.0.8+-14196175-b1038.72)
    ! Some Android licenses not accepted. To resolve this, run: flutter doctor --android-licenses

[√] Chrome - develop for the web [63ms]
    • Chrome at C:\Program Files\Google\Chrome\Application\chrome.exe

[√] Visual Studio - develop Windows apps (Visual Studio Community 2026 18.2.0) [63ms]
    • Visual Studio at C:\Program Files\Microsoft Visual Studio\18\Community
    • Visual Studio Community 2026 version 18.2.11408.102
    • Windows 10 SDK version 10.0.26100.0

[√] Connected device (3 available) [129ms]
    • Windows (desktop) • windows • windows-x64    • Microsoft Windows [Version 10.0.26200.7840]
    • Chrome (web)      • chrome  • web-javascript • Google Chrome 145.0.7632.117
    • Edge (web)        • edge    • web-javascript • Microsoft Edge 144.0.3719.92

[√] Network resources [530ms]
    • All expected network resources are available.

! Doctor found issues in 2 categories.

(originally raised at Dart-Code/Dart-Code#5942 by @Wdestroier)

Metadata

Metadata

Assignees

Labels

P2Important issues not at the top of the work listplatform-webWeb applications specificallyteam-toolOwned by Flutter Tool teamtriaged-toolTriaged by Flutter Tool team

Type

No type

Projects

No projects

Milestone

No milestone

Relationships

None yet

Development

No branches or pull requests

Issue actions