好消息: Flutter Skill 现在自动处理 Flutter 3.x 兼容性!
从 v0.3.2 开始,launch_app 工具会自动添加 --vm-service-port=50000,
你不需要手动指定这个参数了。
Flutter 3.x 默认使用 DTD 协议,不启动 VM Service。flutter-skill 依赖 VM Service,因此必须强制启动。
只需正常使用,无需额外参数!
// 最简单的方式 - VM Service 端口自动添加!
launch_app(
project_path: "/path/to/project",
device_id: "iPhone 16 Pro"
)
// ↑ 内部自动变成: flutter run -d "iPhone 16 Pro" --vm-service-port=50000
// 如果需要自定义端口(可选)
launch_app(
project_path: "/path/to/project",
device_id: "iPhone 16 Pro",
extra_args: ["--vm-service-port=8888"] // 自定义端口
)# 简单命令 - 自动添加 --vm-service-port=50000
flutter_skill launch . -d "iPhone 16 Pro"
# 或手动指定端口
flutter_skill launch . -d "iPhone 16 Pro" --vm-service-port=8888# 1. 启动应用(需手动指定 VM Service)
flutter run -d "iPhone 16 Pro" --vm-service-port=50000
# 2. 复制输出的 VM Service URI,例如:
# The Dart VM service is listening on http://127.0.0.1:50000/xxxx=/
# 3. 连接
connect_app(uri: "http://127.0.0.1:50000/xxxx=/")// 旧版本需要手动指定(v0.3.1 及更早)
launch_app(
extra_args: ["--vm-service-port=50000"] // ← 现在不再需要!
)现在你不需要这样做了! 工具会自动处理。
flutter run --observatory-port=54321 # ❌ Flutter 3.x 已废弃flutter run # ❌ 只会启动 DTD,不会启动 VM Serviceconnect_app(uri: "ws://127.0.0.1:52049/xxx=/ws") # ❌ 这是 DTD URI,不是 VM Servicehttp://127.0.0.1:50000/xxxx=/
ws://127.0.0.1:50000/xxxx=/ws
- 包含
http://或ws:// - 通常在 "Dart VM service is listening" 消息后出现
ws://127.0.0.1:52049/xxx=/ws
- 只包含
ws:// - 在 "Dart Tooling Daemon" 消息后出现
- flutter-skill 不支持 DTD
启动后应该看到:
[Flutter]: The Dart VM service is listening on http://127.0.0.1:50000/xxxx=/
✅ Connected to http://127.0.0.1:50000/xxxx=/
原因: 应用可能未正确启动 VM Service 解决:
- 检查 Flutter 输出中是否有 "Dart VM service is listening" 消息
- 确认使用了
--vm-service-port=50000标志 - 重启应用
原因: 连接失败导致 _service 未初始化 解决: 修复连接问题(见上)
原因: 忘记加 --vm-service-port 标志
解决: 添加 --vm-service-port=50000 到启动命令
| Flutter 版本 | 默认协议 | 需要 --vm-service-port? |
|---|---|---|
| 2.x | VM Service | ❌ 不需要 |
| 3.0-3.24 | VM Service | |
| 3.25+ | DTD | ✅ 必须 |
- Flutter VM Service: https://dart.dev/tools/dart-devtools
- DTD Protocol: https://github.com/dart-lang/sdk/blob/main/pkg/dtd/README.md