Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

VSCode and flutter, how to connect multiple devices?

I am using Visual Studio Code on macOS for developing Flutter apps.

I can select a single device in the bottom-left of VSC. I can also run on multiple devices using flutter run -d all. I am wondering how I can run on multiple devices using the debug console in VSC. Or, at the very least, debug one device but show updates on all.

Thank you

like image 405
Luke Pighetti Avatar asked Jun 15 '18 14:06

Luke Pighetti


People also ask

How do I run a Flutter App on multiple devices?

Using: Android Studio 3.2.1 Flutter 1.0.0 Dart 2.1.0 Show activity on this post. and go to "Run" -> "Edit Configurations". Press "+" in upper left corner -> select "Bash". Then set: Select "runall" instead of "main.dart" beside run icon. Performing run (also through shortcut) will now run app on all devices.

Does flutter support multi device debugging in VS Code?

In Flutter 1.12 support multi device debugging in VS Code https://github.com/flutter/flutter/wiki/Multi-device-debugging-in-VS-Code well you can run only two devices or two virtual machine at the same time one using command flutter run -d <put the id of the device> If you have different flavors, you can configure your launch.json config as follows.

How to check if flutter is installed on Visual Studio Code?

If you restart Visual Studio Code and load your Flutter project. The new device should show up at the bottom right of the footer. Show activity on this post. run this command in your Visual Studio Code terminal flutter emulators then see the result if you have installed any emulator it will show you.

How do I select a device in VSCode?

You can see the bottom menu in VScode, click on this button and you will able to see all the available devices. Show activity on this post. To select a device you must first start both, Android Studio and your virtual device.


2 Answers

If you're on recent versions of Flutter and the Dart/Flutter extensions (Dec 2019 onwards) this is now supported using VS Code's compound launch configurations.

Your .vscode/launch.json should contain an entry for each device, along with its deviceId (this is the ID you would pass to flutter run -d xxx):

{
    "version": "0.2.0",
    "configurations": [
        {
            "name": "Current Device",
            "request": "launch",
            "type": "dart"
        },
        {
            "name": "Android",
            "request": "launch",
            "type": "dart",
            "deviceId": "android"
        },
        {
            "name": "iPhone",
            "request": "launch",
            "type": "dart",
            "deviceId": "iphone"
        },
    ],
    "compounds": [
        {
            "name": "All Devices",
            "configurations": ["Android", "iPhone"],
        }
    ]
}

For more information, see https://github.com/flutter/flutter/wiki/Multi-device-debugging-in-VS-Code.

like image 77
Danny Tuppeny Avatar answered Oct 23 '22 18:10

Danny Tuppeny


How about this one, it worked for me

flutter run -d all
like image 31
Anirudh Bagri Avatar answered Oct 23 '22 19:10

Anirudh Bagri