How to run your flutter app on multiple emulator devices using vscode

How to run your flutter app on multiple emulator devices using vscode

Flutter is a cross-platform mobile framework i.e its support for Android, iOS, macOS, Window, Linux e.t.c, developing flutter is so fascinating that you get to write once and run on all platforms. in this post, I will be showing how to run more than one emulator concurrently using Visual studio code, by default you can only run a single emulator at a time on a project. Thanks to super-fast hot reload and restart feature of flutter which makes development experience faster and better. But it would have been better if you can be testing/debugging your application as you are developing on all platform's devices without you have to wait for one device.

Steps

  • Create different emulator devices you want to run your application on. e.g iOS devices, Android device

NB: I won't be showing how to create emulator devices, follow below link on how to create the emulator

How to create Android and iOS emulator device .

  • Make sure all the devices are launched.i.e all devices for iOS and Android.

  • Get ID for all your devices, to get the device id run flutter devices on your terminal to get your device id. [screenshot below]

Screenshot 2020-05-10 at 7.18.03 PM.png

  • Create a launch configuration setting for your flutter project. [screenshot below]

Screenshot 2020-05-10 at 6.53.34 PM.png

  • Create a device profile for each of the devices in the launch.json
{
      "name": "iPad Pro",
      "request": "launch",
      "type": "dart",
      "deviceId": "CE96E50B-A047-40D9-9921-1359CA2CF231"

}

NB: name is the profile name i.e device name although it can be any name. below is the sample configuration setting for my flutter app

{
  // 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": "Flutter",
      "request": "launch",
      "type": "dart"
    },
    {
      "name": "Android",
      "request": "launch",
      "type": "dart",
      "deviceId": "emulator-5554"
    },
    {
      "name": "iPhone",
      "request": "launch",
      "type": "dart",
      "deviceId": "iPhone"
    },
    {
      "name": "iPad Pro",
      "request": "launch",
      "type": "dart",
      "deviceId": "CE96E50B-A047-40D9-9921-1359CA2CF231"
    }
  ],
  "compounds": [
    {
      "name": "All Devices",
      "configurations": ["Android", "iPhone", "iPad Pro"]
    }
  ]
}
  • Screenshot 2020-05-10 at 7.36.17 PM.png