user3881465
user3881465

Reputation: 269

How to run flutter app on web and android emulator simultaneously in VS Code?

I want to run my flutter app on web and in emulator simultaneously in VS Code. But I am only able to run it in either web or emulator one by one but not simultaneously.

Upvotes: 1

Views: 1707

Answers (1)

Danny Tuppeny
Danny Tuppeny

Reputation: 42333

You can create a compound launch config in your .vscode/launch.json that launches two configs that each specify a deviceId.

This one creates three configs, one to launch on the current device (shown in the status bar), one to launch on iOS, and one to launch on Android. It then creates a compound config that will launch on iOS and Android devices at the same time. You can change one of the device IDs to chrome to launch on Chrome.

{
    "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"],
        }
    ]
}

More info can be found on the Flutter wiki.

Upvotes: 3

Related Questions