Takamura's blog

Run a Flutter app on a specific device from VS Code

We’ll do it using a custom launch.json configuration in VS Code.

Step 1: Launch the desired device

Make sure your desired device is up and running. If you’re using an emulator, launch it from VS Code by pressing Command+Shift+p and searching for Flutter: Launch Emulator.

Step 2: Get device ids

Identify available devices and their IDs by running this command in your terminal:

flutter devices

You’ll see a list of all connected devices, including emulators and physical devices, along with their respective IDs. The ID is in the second column.

Step 3: Create launch.json

Now, create a .vscode/launch.json file in your project directory. Here’s an example:

{
    // Use IntelliSense to learn about possible attributes.
    // Hover to view descriptions of existing attributes.
    // For more information, visit: https://go.microsoft.com/fwlink/?linkid=830387
    "version": "0.2.0",
    "configurations": [
        {
            "name": "Android",
            "request": "launch",
            "type": "dart",
            "flutterMode": "debug",
            "deviceId": "emulator-5554"
        },
        {
            "name": "macOS",
            "request": "launch",
            "type": "dart",
            "flutterMode": "debug",
            "deviceId": "macos"
        },
        {
            "name": "iOS",
            "request": "launch",
            "type": "dart",
            "flutterMode": "debug",
            "deviceId": "82D137D8-B58B-442D-8378-5ABA08D27B63"
        }
    ]
}

You can learn more about the Launch Configuration here.