Sub topic 5
Choosing Where to Run Your Flutter App
This chapter assumes that you have installed the Flutter SDK and can use a terminal. You should also understand basic commands, files, and classes. A run target is the device or platform where Flutter builds and launches your app.
Flutter can target several environments:
| Run target | Best use | Typical command |
|---|---|---|
| Android emulator | Android development without a phone | `flutter run -d <device-id>` |
| iOS simulator | iOS development on macOS | `flutter run -d <device-id>` |
| Web browser | Fast UI checks and web development | `flutter run -d chrome` |
| Desktop | Windows, macOS, or Linux app development | `flutter run -d <device-id>` |
| Physical device | Hardware behavior and final checks | `flutter run -d <device-id>` |
List the available targets
From a Flutter project directory, run:
flutter devicesFlutter prints the targets that it can find. Each target has a name, a platform, and a device identifier. For example, the output might include Chrome, an Android emulator, and a connected phone.
You can also inspect the complete toolchain:
flutter doctorA target can appear in flutter devices only when its related tools are configured correctly. For example, an Android emulator requires Android tooling and an available virtual device. An iOS simulator requires macOS with Xcode installed. A physical Android phone usually requires developer options and USB debugging.
If Flutter reports no devices, check these points:
- Start the emulator or simulator before running the app.
- Connect the physical device and approve its debugging prompt.
- Confirm that the browser or desktop platform is enabled.
- Run
flutter doctorand follow the missing-component messages. - Check that your editor is using the same Flutter SDK as your terminal.
Start an app on a selected target
If only one target is available, this command usually selects it automatically:
flutter runWhen several targets are available, specify one with -d:
flutter run -d chromeUse the identifier shown by flutter devices, not an identifier copied from a different computer. To see all possible identifiers, use:
flutter devicesFlutter then compiles the app for that platform, installs or serves it, and starts it. The terminal shows commands for actions such as hot reload and stopping the process.
Compare target types
A browser is often the quickest target for checking layout and navigation. It does not prove that mobile permissions, sensors, platform plugins, or native performance work correctly.
An emulator or simulator gives you a mobile-like environment. It is convenient for repeatable testing, but it may not match real hardware speed, screen size, or system behavior.
A physical device provides the most realistic hardware check. It can expose problems with permissions, network conditions, keyboard behavior, and device-specific layouts. Use it before treating a mobile feature as complete.
Desktop targets are useful when your application is intended for a desktop operating system. A desktop build may need platform-specific window behavior and plugins.
Exercise
You have Chrome and an Android emulator listed by flutter devices. Which command launches the app in Chrome, and why might you still test the emulator?
Show answer
Run flutter run -d chrome. The emulator can reveal mobile-specific layout, permissions, and plugin behavior that a browser may not reproduce.