Sub topic 5
Choosing where to run your app
This chapter assumes you have installed the Flutter SDK and that flutter doctor runs without fatal errors. It also assumes you can use a terminal and know the basic difference between a phone, a desktop app, and a web page. By the end you will know which run targets Flutter supports, how to list and select them, and how to fix the usual "no devices" problems.
What a run target is
A run target is the place where flutter run installs and starts your app. Flutter uses one Dart codebase, but it compiles that code differently for each target. The tool calls every target a device, even when it is a browser tab or your own computer.
Flutter supports these target families:
| Target | Typical device ID | Needs | Typical use |
|---|---|---|---|
| Android emulator | `emulator-5554` | Android Studio, Android SDK, an AVD | Testing Android without hardware |
| iOS simulator | a UUID | macOS, Xcode | Testing iPhone and iPad layouts |
| Physical phone or tablet | serial number or UDID | USB cable or wireless debugging, developer mode | Real performance, sensors, camera |
| Chrome (web) | `chrome` | Chrome installed | Fastest first run, no extra setup |
| Edge (web) | `edge` | Edge on Windows | Browser testing on Windows |
| Web server | `web-server` | Any browser you open yourself | Remote or unusual browsers |
| Desktop | `windows`, `macos`, `linux` | Platform build tools | Desktop apps, quick local runs |
The desktop and web targets work only on a matching or capable host. You can build for Windows only on Windows, for macOS and iOS only on macOS, and for Linux only on Linux. Android and web work on all three.
Listing what Flutter can see
Run this command to see every target Flutter can currently use:
flutter devicesThe output has one line per device with its name, its ID, its platform, and its operating system version. The ID is what you pass to other commands. If a device is not listed here, flutter run cannot use it, so this is the first place to look when something is missing.
To see the emulators you have created but not started, run:
flutter emulatorsTo start one by its ID, run this (the ID Pixel_8_API_35 is an example; use one from your own list):
flutter emulators --launch Pixel_8_API_35Once the emulator has booted, it appears in flutter devices.
Selecting a target for `flutter run`
If exactly one device is available, flutter run uses it. If several are available, the tool asks you to choose. To skip the question, pass the ID with -d:
flutter run -d chrome
flutter run -d emulator-5554
flutter run -d macosYou can also run on every connected device at once with flutter run -d all. This is useful for comparing how one screen looks on a phone and in a browser. Be aware that hot reload then applies to all of them, and the console output from each is mixed together.
Which target should you start with?
Pick the target that needs the least setup, then add others as you need them. A reasonable order is:
- Chrome or your host desktop. Both need almost nothing beyond the SDK, so they confirm that your code works.
- An emulator or simulator, once you care about phone-sized screens, safe areas, and platform behavior.
- A physical device, when you need to judge real speed, touch feel, camera, GPS, or Bluetooth.
Android emulators
An Android emulator is a virtual phone that runs on your computer. You create one in Android Studio under Device Manager. Each virtual device is called an AVD (Android Virtual Device) and combines a hardware profile, such as a Pixel model, with a system image, which is a copy of Android.
Points to check when you create one:
- Choose a system image that matches your computer's processor. On Intel or AMD machines use x86_64 images. On Apple silicon Macs use arm64 images. A mismatched image runs very slowly or not at all.
- Enable hardware acceleration. Windows and Linux use virtualization support from the processor (set in BIOS or UEFI), and macOS uses the built-in hypervisor.
- Accept the Android SDK licenses, which
flutter doctor --android-licenseswalks you through.
iOS simulators
An iOS simulator runs on macOS only and comes with Xcode. A simulator is not an emulator. It runs iOS code compiled for your Mac's processor instead of imitating phone hardware, so it starts fast but cannot show real hardware performance.
Open one from the terminal with:
open -a SimulatorThen run flutter devices to confirm it is listed. If Xcode was just installed, you may need to accept its license and select its command-line tools once:
sudo xcode-select --switch /Applications/Xcode.app/Contents/Developer
sudo xcodebuild -runFirstLaunchWeb, desktop, and the host machine
Web and desktop are the cheapest targets because they need no virtual machine. Enable them if they do not show up in flutter devices:
flutter config --enable-web
flutter config --enable-windows-desktop
flutter config --enable-macos-desktop
flutter config --enable-linux-desktopUse only the line that matches your operating system. Recent Flutter versions enable these by default, so the commands may report nothing new.
An existing project may lack the platform folders. Add them with flutter create, run from the project root:
flutter create --platforms=web,windows .This adds web/ and windows/ folders without touching your lib/ code.
Physical devices
A real device gives the most honest results. The setup differs by platform.
Android
- Open Settings, then About phone, and tap Build number seven times to unlock Developer options.
- In Developer options, turn on USB debugging.
- Connect the phone by USB and accept the "Allow USB debugging?" prompt on its screen.
- Run
flutter devicesand confirm the phone is listed.
Android 11 and later also support wireless debugging, which you pair once from Developer options using adb pair. On Windows you may need the OEM USB driver for your phone brand.
iOS
- Connect the iPhone to your Mac and tap Trust on the phone.
- Turn on Developer Mode in Settings, then Privacy & Security. The phone restarts.
- Open
ios/Runner.xcworkspacein Xcode and, under Signing & Capabilities, select your development team. A free Apple ID works for personal testing, though those builds expire after a short period. - Run
flutter runfrom the terminal.
Common failures
| Symptom | Likely cause | Fix |
|---|---|---|
| `flutter devices` shows only Chrome and desktop | No emulator running and no phone connected | Start an emulator or connect a device |
| Phone is missing from the list | USB debugging off, cable is charge-only, prompt not accepted | Use a data cable, re-enable USB debugging, accept the prompt |
| Device shows as `unauthorized` | You have not accepted the debugging prompt | Unplug, replug, and accept the prompt on the phone |
| Emulator is very slow | Wrong system image or acceleration off | Recreate the AVD with the right image and enable acceleration |
| iOS run fails on signing | No development team selected | Set a team in Xcode |
| Chrome not found | `CHROME_EXECUTABLE` not set or Chrome missing | Install Chrome or set the variable to its path |
When a device appears in some tools but not in Flutter, run flutter doctor -v. The verbose output names the exact check that fails.
Putting it together
This sequence takes a fresh project from nothing to a running app on a target you choose:
flutter devices
flutter create my_first_app
cd my_first_app
flutter run -d chromeUse the ID shown by flutter devices in place of chrome to switch targets. Because the project is the same, you can run it on a second target later without changing any code.
Exercise
Your Android phone is plugged in by USB, but flutter devices lists only Chrome and your desktop. Name three things to check, in the order you would check them.
Show answer
First, confirm the cable carries data and not only power, by trying another cable or port. Second, confirm Developer options and USB debugging are turned on, and that you accepted the "Allow USB debugging?" prompt on the phone. Third, run flutter doctor -v to see whether the Android toolchain or licenses are the problem, and on Windows check that the phone's USB driver is installed.
Exercise
You want to run your app on an Android emulator whose ID is emulator-5554 while a Chrome window is also open. Which command selects the emulator, and how do you run on both?
Show answer
Use flutter run -d emulator-5554 for the emulator alone. Use flutter run -d all to run on every connected device, which includes Chrome and the emulator.