21

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

5 Answers 5

37

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.

Sign up to request clarification or add additional context in comments.

2 Comments

Review your answer. As of now, it is supported
Nice reference. The one thing missing from that article is how to find your deviceId (say if you have to set a new one up later) --- From a terminal, run flutter devices. The first column is the device's name; the second is the deviceId. This helped me find and set my Android deviceId, and launch my Android emulator. However, the deviceId for the iPhone in the configurations list (which was set when launch.json was created) doesn't match the deviceId in the flutter devices results, but... the iPhone emulator still works, and comes up right alongside the Android emulator.
6

How about this one, it worked for me

flutter run -d all 

Comments

4

In Flutter 1.12 support multi device debugging in VS Code https://github.com/flutter/flutter/wiki/Multi-device-debugging-in-VS-Code

Comments

3

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>

and the other using f5 and choose the other device

1 Comment

No, you can actually run more than two. I have 2 emulator and a device running currently.
3

If you have different flavors, you can configure your launch.json config as follows.

{ "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

Now you can select the All Device and hit run.

Comments

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.