Repository: flutter
Issue: Environment flags passed in by --dart-define not being set in Flutter driver on the web
Labels: tool,platform-web,P2,team-web,triaged-web

<!-- Thank you for using Flutter!

     If you are looking for support, please check out our documentation
     or consider asking a question on Stack Overflow:
      * https://flutter.dev/
      * https://api.flutter.dev/
      * https://stackoverflow.com/questions/tagged/flutter?sort=frequent

     If you have found a bug or if our documentation doesn't have an answer
     to what you're looking for, then fill out the template below. Please read
     our guide to filing a bug first: https://flutter.dev/docs/resources/bug-reports
-->

## Steps to Reproduce

<!-- You must include full steps to reproduce so that we can reproduce the problem. -->

1. Create a simple test in app.test and app_test.dart 
```
void main() {
  enableFlutterDriverExtension();
  app.main();
}
```


```
void main() {
  String blah = const String.fromEnvironment('test', defaultValue: 'no');
  print(blah);
}
```

2. Run flutter driver `flutter drive --dart-define=test=yes --target=test_driver/app.dart` ensuring chromedriver is running  
and select to run using Web Sever from flutter tools

**Expected results:** <!-- what did you want to see? -->
`yes`
**Actual results:** <!-- what did you see? -->
`no`
<details>
  <summary>Logs</summary>

<!--
      Run your application with `flutter run --verbose` and attach all the
      log output below between the lines with the backticks. If there is an
      exception, please see if the error message includes enough information
      to explain how to solve the issue.
-->

```
lewis-dev ❯ flutter drive --dart-define=test=yes --target=test_driver/app.dart --verbose
[ +108 ms] executing: [/home/lewis/flutter/] git -c log.showSignature=false log -n 1 --pretty=format:%H
[  +30 ms] Exit code 0 from: git -c log.showSignature=false log -n 1 --pretty=format:%H
[        ] 81a45ec2e5f80fa71d5135f1702ce540558b416d
[        ] executing: [/home/lewis/flutter/] git tag --contains HEAD
[ +703 ms] Exit code 0 from: git tag --contains HEAD
[        ] 1.21.0-9.2.pre
[  +11 ms] executing: [/home/lewis/flutter/] git rev-parse --abbrev-ref --symbolic @{u}
[   +3 ms] Exit code 0 from: git rev-parse --abbrev-ref --symbolic @{u}
[        ] origin/beta
[        ] executing: [/home/lewis/flutter/] git ls-remote --get-url origin
[   +2 ms] Exit code 0 from: git ls-remote --get-url origin
[        ] https://github.com/flutter/flutter.git
[  +36 ms] executing: [/home/lewis/flutter/] git rev-parse --abbrev-ref HEAD
[   +2 ms] Exit code 0 from: git rev-parse --abbrev-ref HEAD
[        ] beta
[  +47 ms] Artifact Instance of 'AndroidMavenArtifacts' is not required, skipping update.
[        ] Artifact Instance of 'AndroidGenSnapshotArtifacts' is not required, skipping update.
[        ] Artifact Instance of 'AndroidInternalBuildArtifacts' is not required, skipping update.
[        ] Artifact Instance of 'IOSEngineArtifacts' is not required, skipping update.
[        ] Artifact Instance of 'FlutterWebSdk' is not required, skipping update.
[   +2 ms] Artifact Instance of 'WindowsEngineArtifacts' is not required, skipping update.
[        ] Artifact Instance of 'MacOSEngineArtifacts' is not required, skipping update.
[        ] Artifact Instance of 'LinuxEngineArtifacts' is not required, skipping update.
[        ] Artifact Instance of 'LinuxFuchsiaSDKArtifacts' is not required, skipping update.
[        ] Artifact Instance of 'MacOSFuchsiaSDKArtifacts' is not required, skipping update.
[        ] Artifact Instance of 'FlutterRunnerSDKArtifacts' is not required, skipping update.
[        ] Artifact Instance of 'FlutterRunnerDebugSymbols' is not required, skipping update.
[  +10 ms] executing: /home/lewis/DevTools/Android/platform-tools/adb devices -l
[ +109 ms] List of devices attached
[  +27 ms] Artifact Instance of 'AndroidMavenArtifacts' is not required, skipping update.
[        ] Artifact Instance of 'AndroidGenSnapshotArtifacts' is not required, skipping update.
[        ] Artifact Instance of 'AndroidInternalBuildArtifacts' is not required, skipping update.
[        ] Artifact Instance of 'IOSEngineArtifacts' is not required, skipping update.
[  +10 ms] Artifact Instance of 'WindowsEngineArtifacts' is not required, skipping update.
[   +1 ms] Artifact Instance of 'MacOSEngineArtifacts' is not required, skipping update.
[        ] Artifact Instance of 'LinuxEngineArtifacts' is not required, skipping update.
[        ] Artifact Instance of 'LinuxFuchsiaSDKArtifacts' is not required, skipping update.
[        ] Artifact Instance of 'MacOSFuchsiaSDKArtifacts' is not required, skipping update.
[   +1 ms] Artifact Instance of 'FlutterRunnerSDKArtifacts' is not required, skipping update.
[        ] Artifact Instance of 'FlutterRunnerDebugSymbols' is not required, skipping update.
[ +352 ms] Found plugin flutter_secure_storage at /home/lewis/flutter/.pub-cache/hosted/pub.dartlang.org/flutter_secure_storage-3.3.3/
[  +16 ms] Found plugin flutter_segment at /home/lewis/flutter/.pub-cache/hosted/pub.dartlang.org/flutter_segment-2.1.1/
[  +75 ms] Found plugin path_provider at /home/lewis/flutter/.pub-cache/hosted/pub.dartlang.org/path_provider-1.6.11/
[   +3 ms] Found plugin path_provider_linux at /home/lewis/flutter/.pub-cache/hosted/pub.dartlang.org/path_provider_linux-0.0.1+2/
[   +4 ms] Found plugin path_provider_macos at /home/lewis/flutter/.pub-cache/hosted/pub.dartlang.org/path_provider_macos-0.0.4+3/
[  +37 ms] Found plugin screen at /home/lewis/flutter/.pub-cache/hosted/pub.dartlang.org/screen-0.0.5/
[  +20 ms] Found plugin sqflite at /home/lewis/flutter/.pub-cache/hosted/pub.dartlang.org/sqflite-1.3.1/
[  +28 ms] Found plugin uni_links at /home/lewis/flutter/.pub-cache/hosted/pub.dartlang.org/uni_links-0.4.0/
[   +8 ms] Found plugin url_launcher at /home/lewis/flutter/.pub-cache/hosted/pub.dartlang.org/url_launcher-5.5.0/
[   +3 ms] Found plugin url_launcher_linux at /home/lewis/flutter/.pub-cache/hosted/pub.dartlang.org/url_launcher_linux-0.0.1+1/
[   +2 ms] Found plugin url_launcher_macos at /home/lewis/flutter/.pub-cache/hosted/pub.dartlang.org/url_launcher_macos-0.0.1+7/
[   +4 ms] Found plugin url_launcher_web at /home/lewis/flutter/.pub-cache/hosted/pub.dartlang.org/url_launcher_web-0.1.2+1/
[   +7 ms] Found plugin video_player at /home/lewis/flutter/.pub-cache/hosted/pub.dartlang.org/video_player-0.10.11+2/
[   +3 ms] Found plugin video_player_web at /home/lewis/flutter/.pub-cache/hosted/pub.dartlang.org/video_player_web-0.1.3+2/
[   +5 ms] Found plugin wakelock at /home/lewis/flutter/.pub-cache/hosted/pub.dartlang.org/wakelock-0.1.4+2/
[   +7 ms] Found plugin webview_flutter at /home/lewis/flutter/.pub-cache/hosted/pub.dartlang.org/webview_flutter-0.3.22+1/
[ +174 ms] Found plugin flutter_secure_storage at /home/lewis/flutter/.pub-cache/hosted/pub.dartlang.org/flutter_secure_storage-3.3.3/
[   +2 ms] Found plugin flutter_segment at /home/lewis/flutter/.pub-cache/hosted/pub.dartlang.org/flutter_segment-2.1.1/
[  +28 ms] Found plugin path_provider at /home/lewis/flutter/.pub-cache/hosted/pub.dartlang.org/path_provider-1.6.11/
[   +1 ms] Found plugin path_provider_linux at /home/lewis/flutter/.pub-cache/hosted/pub.dartlang.org/path_provider_linux-0.0.1+2/
[   +3 ms] Found plugin path_provider_macos at /home/lewis/flutter/.pub-cache/hosted/pub.dartlang.org/path_provider_macos-0.0.4+3/
[  +19 ms] Found plugin screen at /home/lewis/flutter/.pub-cache/hosted/pub.dartlang.org/screen-0.0.5/
[  +12 ms] Found plugin sqflite at /home/lewis/flutter/.pub-cache/hosted/pub.dartlang.org/sqflite-1.3.1/
[  +18 ms] Found plugin uni_links at /home/lewis/flutter/.pub-cache/hosted/pub.dartlang.org/uni_links-0.4.0/
[   +3 ms] Found plugin url_launcher at /home/lewis/flutter/.pub-cache/hosted/pub.dartlang.org/url_launcher-5.5.0/
[   +3 ms] Found plugin url_launcher_linux at /home/lewis/flutter/.pub-cache/hosted/pub.dartlang.org/url_launcher_linux-0.0.1+1/
[   +1 ms] Found plugin url_launcher_macos at /home/lewis/flutter/.pub-cache/hosted/pub.dartlang.org/url_launcher_macos-0.0.1+7/
[   +3 ms] Found plugin url_launcher_web at /home/lewis/flutter/.pub-cache/hosted/pub.dartlang.org/url_launcher_web-0.1.2+1/
[   +5 ms] Found plugin video_player at /home/lewis/flutter/.pub-cache/hosted/pub.dartlang.org/video_player-0.10.11+2/
[   +2 ms] Found plugin video_player_web at /home/lewis/flutter/.pub-cache/hosted/pub.dartlang.org/video_player_web-0.1.3+2/
[   +3 ms] Found plugin wakelock at /home/lewis/flutter/.pub-cache/hosted/pub.dartlang.org/wakelock-0.1.4+2/
[   +5 ms] Found plugin webview_flutter at /home/lewis/flutter/.pub-cache/hosted/pub.dartlang.org/webview_flutter-0.3.22+1/
[ +160 ms] Generating /mnt/c/Users/Lewis/PycharmProjects/maxwell/maxwell_flutter/android/app/src/main/java/io/flutter/plugins/GeneratedPluginRegistrant.java
[ +176 ms] Multiple devices found:
[ +277 ms] Web Server (web) • web-server • web-javascript • Flutter Tools
[   +2 ms] Chrome (web)     • chrome     • web-javascript • Google Chrome 83.0.4103.116
[   +4 ms] [0]: Web Server (web-server)
[        ] [1]: Chrome (chrome)
[   +3 ms] Please choose one:
[        ]  [0|1]
[        ] : 
[+2413 ms] 0
[   +4 ms] Starting application: test_driver/app.dart
[  +30 ms] Launching test_driver/app.dart on Web Server in debug mode...
[  +35 ms] Updating assets
[ +191 ms] Manifest contained wildcard assets. Inserting missing file into build graph to force rerun. for more information see #56466.
[   +9 ms] Syncing files to device Web Server...
[  +16 ms] Found plugin flutter_secure_storage at /home/lewis/flutter/.pub-cache/hosted/pub.dartlang.org/flutter_secure_storage-3.3.3/
[        ] Found plugin flutter_segment at /home/lewis/flutter/.pub-cache/hosted/pub.dartlang.org/flutter_segment-2.1.1/
[   +3 ms] Found plugin path_provider at /home/lewis/flutter/.pub-cache/hosted/pub.dartlang.org/path_provider-1.6.11/
[        ] Found plugin path_provider_linux at /home/lewis/flutter/.pub-cache/hosted/pub.dartlang.org/path_provider_linux-0.0.1+2/
[        ] Found plugin path_provider_macos at /home/lewis/flutter/.pub-cache/hosted/pub.dartlang.org/path_provider_macos-0.0.4+3/
[   +2 ms] Found plugin screen at /home/lewis/flutter/.pub-cache/hosted/pub.dartlang.org/screen-0.0.5/
[   +1 ms] Found plugin sqflite at /home/lewis/flutter/.pub-cache/hosted/pub.dartlang.org/sqflite-1.3.1/
[   +2 ms] Found plugin uni_links at /home/lewis/flutter/.pub-cache/hosted/pub.dartlang.org/uni_links-0.4.0/
[        ] Found plugin url_launcher at /home/lewis/flutter/.pub-cache/hosted/pub.dartlang.org/url_launcher-5.5.0/
[        ] Found plugin url_launcher_linux at /home/lewis/flutter/.pub-cache/hosted/pub.dartlang.org/url_launcher_linux-0.0.1+1/
[        ] Found plugin url_launcher_macos at /home/lewis/flutter/.pub-cache/hosted/pub.dartlang.org/url_launcher_macos-0.0.1+7/
[        ] Found plugin url_launcher_web at /home/lewis/flutter/.pub-cache/hosted/pub.dartlang.org/url_launcher_web-0.1.2+1/
[        ] Found plugin video_player at /home/lewis/flutter/.pub-cache/hosted/pub.dartlang.org/video_player-0.10.11+2/
[        ] Found plugin video_player_web at /home/lewis/flutter/.pub-cache/hosted/pub.dartlang.org/video_player_web-0.1.3+2/
[        ] Found plugin wakelock at /home/lewis/flutter/.pub-cache/hosted/pub.dartlang.org/wakelock-0.1.4+2/
[        ] Found plugin webview_flutter at /home/lewis/flutter/.pub-cache/hosted/pub.dartlang.org/webview_flutter-0.3.22+1/
[  +18 ms] Found plugin flutter_secure_storage at /home/lewis/flutter/.pub-cache/hosted/pub.dartlang.org/flutter_secure_storage-3.3.3/
[        ] Found plugin flutter_segment at /home/lewis/flutter/.pub-cache/hosted/pub.dartlang.org/flutter_segment-2.1.1/
[   +4 ms] Found plugin path_provider at /home/lewis/flutter/.pub-cache/hosted/pub.dartlang.org/path_provider-1.6.11/
[        ] Found plugin path_provider_linux at /home/lewis/flutter/.pub-cache/hosted/pub.dartlang.org/path_provider_linux-0.0.1+2/
[        ] Found plugin path_provider_macos at /home/lewis/flutter/.pub-cache/hosted/pub.dartlang.org/path_provider_macos-0.0.4+3/
[   +2 ms] Found plugin screen at /home/lewis/flutter/.pub-cache/hosted/pub.dartlang.org/screen-0.0.5/
[   +1 ms] Found plugin sqflite at /home/lewis/flutter/.pub-cache/hosted/pub.dartlang.org/sqflite-1.3.1/
[   +2 ms] Found plugin uni_links at /home/lewis/flutter/.pub-cache/hosted/pub.dartlang.org/uni_links-0.4.0/
[        ] Found plugin url_launcher at /home/lewis/flutter/.pub-cache/hosted/pub.dartlang.org/url_launcher-5.5.0/
[        ] Found plugin url_launcher_linux at /home/lewis/flutter/.pub-cache/hosted/pub.dartlang.org/url_launcher_linux-0.0.1+1/
[        ] Found plugin url_launcher_macos at /home/lewis/flutter/.pub-cache/hosted/pub.dartlang.org/url_launcher_macos-0.0.1+7/
[        ] Found plugin url_launcher_web at /home/lewis/flutter/.pub-cache/hosted/pub.dartlang.org/url_launcher_web-0.1.2+1/
[        ] Found plugin video_player at /home/lewis/flutter/.pub-cache/hosted/pub.dartlang.org/video_player-0.10.11+2/
[        ] Found plugin video_player_web at /home/lewis/flutter/.pub-cache/hosted/pub.dartlang.org/video_player_web-0.1.3+2/
[        ] Found plugin wakelock at /home/lewis/flutter/.pub-cache/hosted/pub.dartlang.org/wakelock-0.1.4+2/
[        ] Found plugin webview_flutter at /home/lewis/flutter/.pub-cache/hosted/pub.dartlang.org/webview_flutter-0.3.22+1/
[  +20 ms] Generating /mnt/c/Users/Lewis/PycharmProjects/maxwell/maxwell_flutter/android/app/src/main/java/io/flutter/plugins/GeneratedPluginRegistrant.java
[ +263 ms] <- reset
[   +4 ms] /home/lewis/flutter/bin/cache/dart-sdk/bin/dart --disable-dart-dev /home/lewis/flutter/bin/cache/artifacts/engine/linux-x64/frontend_server.dart.snapshot --sdk-root
/home/lewis/flutter/bin/cache/flutter_web_sdk/ --incremental --target=dartdevc --debugger-module-names --experimental-emit-debug-metadata -Ddart.developer.causal_async_stacks=true -Dtest=yes --output-dill
/tmp/flutter_tools.MPKRJM/flutter_tool.RXOLUW/app.dill --libraries-spec file:///home/lewis/flutter/bin/cache/flutter_web_sdk/libraries.json --packages .packages -Ddart.vm.profile=false
-Ddart.vm.product=false --bytecode-options=source-positions,local-var-info,debugger-stops,instance-field-initializers,keep-unreachable-code,avoid-closure-call-instructions --enable-asserts
--track-widget-creation --filesystem-root /mnt/c/Users/Lewis/PycharmProjects/maxwell/maxwell_flutter/test_driver --filesystem-root /mnt/c/Users/Lewis/PycharmProjects/maxwell/maxwell_flutter/test
--filesystem-root /tmp/flutter_tools.MPKRJM/flutter_tools.PJACOX --filesystem-scheme org-dartlang-app --initialize-from-dill build/f524cac7848abbf2dc14a59f10f8bb49.cache.dill.track.dill --platform
file:///home/lewis/flutter/bin/cache/flutter_web_sdk/kernel/flutter_ddc_sdk.dill
[   +7 ms] <- compile org-dartlang-app:/web_entrypoint.dart
[+11302 ms] Syncing files to device Web Server... (completed in 11,653ms, longer than expected)
[        ] Synced 37.5MB.
[        ] <- accept
[        ] Caching compiled dill
[ +520 ms] test_driver/app.dart is being served at http://localhost:39325
[        ] The web-server device requires the Dart Debug Chrome extension for debugging. Consider using the Chrome or Edge devices for an improved development workflow.
[   +4 ms] Application finished.
[   +4 ms] Stopping previously running application, if any.
[        ] Stopping application.
[        ] Installing application package.
[        ] Starting application.
[        ] Waiting for connection from Dart debug extension at http://localhost:39325
[        ] The web-server device requires the Dart Debug Chrome extension for debugging. Consider using the Chrome or Edge devices for an improved development workflow.
[ +679 ms] Running driver tests.
[   +1 ms] executing: /home/lewis/flutter/bin/cache/dart-sdk/bin/dart /mnt/c/Users/Lewis/PycharmProjects/maxwell/maxwell_flutter/test_driver/app_test.dart
--packages=/mnt/c/Users/Lewis/PycharmProjects/maxwell/maxwell_flutter/.packages -rexpanded
[+1961 ms] no
[  +86 ms] Stopping application instance.
[        ] Stopping application.
[        ] "flutter drive" took 19,295ms.
[ +254 ms] ensureAnalyticsSent: 251ms
[   +1 ms] Running shutdown hooks
[        ] Shutdown hook priority 4
[        ] Shutdown hooks complete
[        ] exiting with code 0
```

<!--
     Run `flutter analyze` and attach any output of that command below.
     If there are any analysis errors, try resolving them before filing this issue.
-->

```

```

<!-- Finally, paste the output of running `flutter doctor -v` here. -->

```
[✓] Flutter (Channel beta, 1.21.0-9.2.pre, on Linux, locale C.UTF-8)
    • Flutter version 1.21.0-9.2.pre at /home/lewis/flutter
    • Framework revision 81a45ec2e5 (3 weeks ago), 2020-08-27 14:14:33 -0700
    • Engine revision 20a9531835
    • Dart version 2.10.0 (build 2.10.0-7.3.beta)

[✓] Android toolchain - develop for Android devices (Android SDK version 28.0.3)
    • Android SDK at /home/lewis/DevTools/Android
    • Platform android-28, build-tools 28.0.3
    • ANDROID_HOME = /home/lewis/DevTools/Android
    • Java binary at: /home/lewis/DevTools/JDK/jdk-10.0.2+13/bin/java
    • Java version OpenJDK Runtime Environment AdoptOpenJDK (build 10.0.2+13)
    • All Android licenses accepted.

[✓] Chrome - develop for the web
    • Chrome at google-chrome

[!] Android Studio (not installed)
    • Android Studio not found; download from https://developer.android.com/studio/index.html
      (or visit https://flutter.dev/docs/get-started/install/linux#android-setup for detailed instructions).

[✓] Connected device (2 available)
    • Web Server (web) • web-server • web-javascript • Flutter Tools
    • Chrome (web)     • chrome     • web-javascript • Google Chrome 83.0.4103.116

! Doctor found issues in 1 category.
```

</details>