In Flutter, how do flutter devices, flutter emulators and flutter run -d work together to run an app on a chosen device?
answer
- list first, then target
- id or name, prefixes allowed
- -d all for every device
- prompt when several match
- no platform folder, not supported
basics
~10 sflutter devices lists connected devices with their ids, flutter emulators --launch starts an emulator or simulator, and flutter run -d <id or name prefix> runs on that device; -d all targets every device.
solid answer
~40 s`flutter devices` lists every connected device, emulator, simulator, desktop and browser target with its id, such as `emulator-5554`, `macos` or `chrome`. `flutter emulators` lists available emulators and `flutter emulators --launch <id>` boots one (`--cold` forces a cold boot on Android). `flutter run -d <id-or-name>` then targets a device; prefixes are allowed, so `-d chr` finds Chrome, and `-d all` runs on every device at once. Without `-d`, a single device is used automatically; with several, the tool prompts `Please choose one` in a terminal or asks you to pass `-d`. A device whose platform folder is missing from the project is listed as found but not supported by this project.
code
bash · 6 linesflutter emulators # list definitions
flutter emulators --launch Pixel_9_API_36 # boot one (add --cold for a cold boot)
flutter devices # e.g. emulator-5554, <simulator UUID>, chrome, macos
flutter run -d emulator-5554 # exact id
flutter run -d chr # prefix of 'chrome'
flutter run -d all # every supported device at oncego deeper
Know flutter devices to list targets, flutter run -d with an id, and flutter emulators --launch to boot an emulator.
Explain id and prefix matching, -d all, the prompt when several devices match, and why a device can be unsupported by a project.
Make device selection deterministic in scripts with explicit ids and machine output, and diagnose missing or unsupported devices quickly.
Decide which device matrix a team runs by default, emulators and simulators versus physical devices, and where each belongs in the workflow.
## Three commands, one workflow Running on a chosen device is a three-step loop: **see** what is available, **start** a device if needed, then **target** it. | Command | Purpose | |---|---| | `flutter devices` | list connected physical devices, running emulators and simulators, desktop and web targets | | `flutter emulators` | list emulator and simulator definitions; `--launch <id>` starts one | | `flutter run -d <device>` | build, install and launch the app on that device with a debug session attached | ## flutter devices Each row shows a name, an **id**, the target platform and OS details. Typical ids: - `emulator-5554` for an Android emulator, or a serial for a physical phone; - a UUID for an iOS simulator or device; - `macos`, `windows`, `linux` for desktop; - `chrome`, `edge` and `web-server` for the web (`web-server` serves the app for any browser you open yourself). On macOS the tool also looks for wirelessly paired iOS devices, which is why listing can take a few seconds; `--device-timeout` extends the wait for slow devices. ## flutter emulators - `flutter emulators` lists the definitions available to launch. - `flutter emulators --launch <id>` boots one; partial ids are accepted. - `--cold` with `--launch` cold-boots an Android emulator instead of restoring a snapshot. - `flutter emulators --create --name <name>` creates a new Android emulator based on a Pixel profile. Once booted, the emulator appears in `flutter devices`. ## flutter run -d `-d` (long form `--device-id`) is a **global** option taking a device **id or name, prefixes allowed**. Resolution rules: 1. **One match** — that device is used. 2. **Several matches** — the tool lists them and, in a terminal, prompts `Please choose one (or "q" to quit)`. 3. **`-d all`** — the app is built and launched on every supported device in parallel. 4. **No `-d` and one supported device** — it is used without asking. 5. **No `-d` and several devices** — a prompt in an interactive terminal; otherwise the message `More than one device connected; please specify a device with the '-d <deviceId>' flag, or use '-d all' to act on all devices.` ## The "not supported by this project" case A device is supported only if the project contains that platform's folder. For an app created with `--platforms android,ios,web`: | Device | Result | |---|---| | Android emulator | runs | | iOS simulator | runs (macOS host only) | | `chrome` | runs | | `macos` desktop | listed under `The following devices were found, but are not supported by this project:` | The fix is not a device setting but a project change: `flutter create --platforms macos .` adds the folder. ## Working habits - Script with ids, not names; names change and prefixes can become ambiguous. - Use `flutter devices --machine` when a script needs JSON. - `flutter logs -d <id>` streams log output of Flutter apps on one device; `-c` clears the history first. ## Physical devices Physical devices appear only once the host trusts them: - **Android** — USB debugging enabled in developer options and the host's key accepted on the phone. - **iOS** — the device paired with the Mac and trusted; on recent iOS versions, Developer Mode enabled in Settings. The tool prints exactly this hint when a device is found but not ready. Until then the device may be missing from `flutter devices` or listed with an error, and no `-d` value can target it.
- Why does flutter run say a connected macOS device is not supported by this project?The tool counts a device as supported only when the project has that platform's folder. A project created with `--platforms android,ios,web` has no `macos/`, so the desktop device is listed as found but not supported. Run `flutter create --platforms macos .` to add it.
- What happens when flutter run is called without -d in a non-interactive shell with two devices connected?It cannot prompt, so it prints that more than one device is connected and asks you to pass `-d <deviceId>` or `-d all`. Scripts should always pass an explicit id.
saying these in an interview costs you the question
- Believes -d requires the full exact device id
- Thinks flutter run always picks the first device silently
- Expects a macOS device to run a project without a macos folder
- Uses adb or simctl directly just to pick the target device
- Does not know -d all exists