Repository: flutter
Issue: `flutter run` accepts empty `--local-engine-host` argument.
Labels: tool,P2,e: local-engine-development,team-tool,triaged-tool

## Updated Issue

EDIT: It turns out that in the issue below, the problem is the `flutter run` line. I used:

```
cd dev/manual_tests
flutter run -d linux --local-engine-host --local-engine=host_debug_unopt  lib/hardware_keyboard.dart
```

When I should have used:

```
cd dev/manual_tests
flutter run -d linux --local-engine-host=host_debug_unopt --local-engine=host_debug_unopt  lib/hardware_keyboard.dart
```
 (notice the argument to `--local-engine-host`)

I think this is just a bug in the option parsing where it interprets the `--local-engine=host_debug_unopt` not as an argument in itself, but as the argument to `--local-engine-host`. It should be checking the argument it receives for '--local-engine-host' (and probably '--local-engine' too, in case the situation is reversed) to make sure it a) doesn't start with "--" and b) exists as a directory. Alternatively, if it's just allowing an empty argument, it shouldn't allow that.

## Original issue filed

I tried adding a new API to the Dart code in my local engine build, built the engine, and wanted to test those changes with updated flutter code from the flutter repo, but I am unable to successfully run an application using the local engine with the updated dart changes.

I built the `host_debug_unopt` engine with:

```
flutter/tools/gn --runtime-mode=debug  --unoptimized  --no-goma  --full-dart-sdk
autoninja -C out/host_debug_unopt
```

and when (in the flutter repo) I run:

```
cd dev/manual_tests
flutter run -d linux --local-engine-host --local-engine=host_debug_unopt  lib/hardware_keyboard.dart
```

This fails to compile because the local version of `sky_engine` doesn't include the Dart changes I've made in the engine, so the newly added API doesn't exist.

I then tried adding something like this to the ` pubspec.yaml` of the app I am running:

```yaml
dependency_overrides:
  sky_engine:
    path: /usr/local/home/gspencer/code/engine/src/out/host_debug_unopt/gen/dart-pkg/sky_engine
```

Which doesn't work, with the same issue: the Dart code doesn't include the new APIs somehow.

I tried removing the `sky_engine` directory in the cache directory and replacing that with a symbolic link to the built `sky_engine` in the engine build, which fixes things for the IDE, but still won't run the app (with the same errors).

I tried also adding the `dependency_overrides` to the `packages/flutter/pubspec.yaml`, but that doesn't help.

I filed https://github.com/flutter/flutter/issues/137268 because I was running into this problem, but as I tried to fix it to run in a number of different ways, I realized that it actually was also just broken.

<details>
<summary>flutter doctor -v</summary>

```
[!] Flutter (Channel [user-branch], 3.16.0-17.0.pre.32, on Debian GNU/Linux rodete 6.5.3-1rodete1-amd64, locale en_US.UTF-8)
    ! Flutter version 3.16.0-17.0.pre.32 on channel [user-branch] at /usr/local/google/home/gspencer/code/flutter
      Currently on an unknown channel. Run `flutter channel` to switch to an official channel.
      If that doesn't fix the issue, reinstall Flutter by following instructions at https://flutter.dev/docs/get-started/install.
    ! Upstream repository git@github.com:gspencergoog/flutter.git is not a standard remote.
      Set environment variable "FLUTTER_GIT_URL" to git@github.com:gspencergoog/flutter.git to dismiss this error.
    • Framework revision e73bce7a7f (2 hours ago), 2023-10-25 08:46:40 -0700
    • Engine revision 6e09ee14e2
    • Dart version 3.3.0 (build 3.3.0-56.0.dev)
    • DevTools version 2.28.1
    • If those were intentional, you can disregard the above warnings; however it is recommended to use "git" directly to perform
      update checks and upgrades.

[✓] Android toolchain - develop for Android devices (Android SDK version 32.1.0-rc1)
    • Android SDK at /usr/local/google/home/gspencer/Android/Sdk
    • Platform android-33, build-tools 32.1.0-rc1
    • ANDROID_HOME = /usr/local/google/home/gspencer/Android/Sdk
    • Java binary at: /usr/bin/java
    • Java version OpenJDK Runtime Environment (build 17.0.8+7-Debian-1)
    • All Android licenses accepted.

[✓] Chrome - develop for the web
    • Chrome at google-chrome

[✓] Linux toolchain - develop for Linux desktop
    • Debian clang version 14.0.6
    • cmake version 3.26.4
    • ninja version 1.11.1
    • pkg-config version 1.8.1

[!] 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)
    • Linux (desktop) • linux  • linux-x64      • Debian GNU/Linux rodete 6.5.3-1rodete1-amd64
    • Chrome (web)    • chrome • web-javascript • Google Chrome 118.0.5993.117

[✓] Network resources
    • All expected network resources are available.

! Doctor found issues in 2 categories.
```

</details>