Repository: flutter
Issue: `flutter run` should notify illegal file paths
Labels: tool,c: proposal,P2,team-tool,triaged-tool

Hyphens are forbidden as a Dart package name, and `flutter create` today already notifies it:
```
❯ flutter create a-b
Signing iOS app for device deployment using developer identity: [redacted]
"a-b" is not a valid Dart package name.

See https://dart.dev/tools/pub/pubspec#name for more information.
```

However, nothing is done if the user renames the folder or, more reasonably, **clones the repo with a different name** with a hyphen in it. And in that case, `flutter run` will report completely unrelated error messages, making the user stuck for hours (which was my case.) 

## Reproduction

(There might be smaller reproduction, but mine gives out an interesting error message.)

Platform: a M2 macbook

1. Create an app `flutter create a_b`, then rename it `mv a_b a-b`.
2. Modify the `lib/main.dart` to call a new method:
```dart
import 'dart:ui';

void main() {
  PlatformDispatcher.instance.addView();
}
```
4. Build a custom engine with a modified `dart:ui`:
    * Add an `void addView()` method to the `PlatformDispatcher` class in `lib/ui/platform_dispatcher.dart` in the engine
    * Build the engine: `ninja -C out/host_debug_unopt`
5. Run `flutter -d macos --local-engine host_debug_unopt run`

The message would be

```
Launching lib/main.dart on macOS in debug mode...
lib/main.dart:13:31: Error: The method 'addView' isn't defined for the class 'PlatformDispatcher'.
 - 'PlatformDispatcher' is from 'dart:ui'.
Try correcting the name to the name of an existing method, or defining a method named 'addView'.
  PlatformDispatcher.instance.addView(1);
                              ^^^^^^^
Target kernel_snapshot failed: Exception

Command PhaseScriptExecution failed with a nonzero exit code
warning: Run script build phase 'Run Script' will be run during every build because it does not specify any outputs. To address this warning, either add output dependencies to the script phase, or configure it to run in every build by unchecking "Based on dependency analysis" in the script phase. (in target 'Flutter Assemble' from project 'Runner')
** BUILD FAILED **

Building macOS application...                                           
Exception: Build process failed
```

So I kept thinking that the compiler could not recognize the modified `dart:ui`, and took hours (with others' help) to find out that it was the package name.

### Proposal

`flutter run` (and `flutter build`?) should detect file path and notify illegal characters.

### Logs
flutter doctor -v

<details>
❯ flutter doctor -v
[✓] Flutter (Channel main, 3.9.0-21.0.pre.3, on macOS 13.3 22E252 darwin-arm64, locale en-US)
    • Flutter version 3.9.0-21.0.pre.3 on channel main at /Users/tongmu/dev/flutter
    • Upstream repository git@github.com:flutter/flutter.git
    • Framework revision a81cb42260 (2 days ago), 2023-04-03 02:21:01 -0400
    • Engine revision 07afddf688
    • Dart version 3.0.0 (build 3.0.0-400.0.dev)
    • DevTools version 2.22.2

[✗] Android toolchain - develop for Android devices
    ✗ Unable to locate Android SDK.
      Install Android Studio from: https://developer.android.com/studio/index.html
      On first launch it will assist you in installing the Android SDK components.
      (or visit https://flutter.dev/docs/get-started/install/macos#android-setup for detailed instructions).
      If the Android SDK has been installed to a custom location, please use
      `flutter config --android-sdk` to update to that location.


[✓] Xcode - develop for iOS and macOS (Xcode 14.2)
    • Xcode at /Applications/Xcode.app/Contents/Developer
    • Build 14C18
    • CocoaPods version 1.11.3

[✓] Chrome - develop for the web
    • Chrome at /Applications/Google Chrome.app/Contents/MacOS/Google Chrome

[✓] Android Studio (version 2021.3)
    • Android Studio at /Applications/Android Studio with Blaze.app/Contents
    • Flutter plugin can be installed from:
      🔨 https://plugins.jetbrains.com/plugin/9212-flutter
    • Dart plugin can be installed from:
      🔨 https://plugins.jetbrains.com/plugin/6351-dart
    • Java version OpenJDK Runtime Environment (build 11.0.13+0-b1751.21-8125866)

[✓] VS Code (version 1.76.1)
    • VS Code at /Applications/Visual Studio Code.app/Contents
    • Flutter extension version 3.60.0

[✓] Connected device (2 available)
    • macOS (desktop) • macos  • darwin-arm64   • macOS 13.3 22E252 darwin-arm64
    • Chrome (web)    • chrome • web-javascript • Google Chrome 111.0.5563.146

[✓] Network resources
    • All expected network resources are available.

! Doctor found issues in 1 category.
</details>