VSCode和flutter,如何连接多个设备?

时间:2018-06-15 14:42:53

标签: visual-studio-code flutter

我在macOS上使用Visual Studio Code来开发Flutter应用程序。

我可以在VSC的左下角选择一个设备。我也可以使用flutter run -d all在多个设备上运行。我想知道如何使用VSC中的调试控制台在多个设备上运行。或者,至少调试一个设备,但显示所有设备的更新。

谢谢

5 个答案:

答案 0 :(得分:1)

不幸的是,这目前无法实现。有两个与此相关的未决问题:

我本周刚刚开始工作的第一个(那是为了支持多个当前的调试会话,其中只有一个是Flutter而另一个是Dart)但是第二个需要在Flutter中进行一些额外的更改才能正常工作所以可能再远一点。

答案 1 :(得分:1)

那么您只能同时运行两个设备或两个虚拟机 一个使用命令flutter run -d <put the id of the device>

和另一个使用f5并选择另一个设备

答案 2 :(得分:0)

这对我有用吗

flutter run -d all

答案 3 :(得分:0)

在Flutter 1.12中,VS Code支持多设备调试 https://github.com/flutter/flutter/wiki/Multi-device-debugging-in-VS-Code

答案 4 :(得分:0)

如果您有不同的口味,则可以按以下方式配置launch.json配置。

{
"version": "0.2.0",
"configurations": [
      // config "Run Dev Android" and "Run Dev Iphone" will be user for multiple debuging,
    {
        "name": "Run Dev Android",
        "request": "launch",
        "deviceId": "SM",
        "type": "dart",
         "program": "lib/app/flavors/main_development.dart",
         "flutterMode": "debug",
         "args": [
             "--flavor", "development",
         ]
       
    },
    {
        "name": "Run Dev Iphone",
        "flutterMode": "debug",
        "deviceId": "Iphone",
         "program": "lib/app/flavors/main_development.dart",
         "type": "dart",
         "args": [
             "--flavor", "development",
         ]
    },
    {
        "name": "Run Dev",
        "program": "lib/app/flavors/main_development.dart",
        "flutterMode": "debug",
        "deviceId": "Android",
        "type": "dart",
        "args": [
            "--flavor", "development",
        ]
    },
    {
        "name": "Run Stage",
        "program": "lib/app/flavors/main_staging.dart",
        "flutterMode": "debug",
        "type": "dart",
        "args": [
            "--flavor", "staging"
        ]
    },
    {
        "name": "Run Prod",
        "program": "lib/app/flavors/main_development.dart",
        "flutterMode": "release",
        "type": "dart",
        "args": [
            "--flavor", "production"
        ]
    },
],
"compounds": [{
        "name": "All Devices",
        "configurations": ["Run Dev Android", "Run Dev Iphone"],
       
    }]

}

enter image description here

现在您可以选择All Device并点击运行。