Before proceeding, make sure that you have set up a working environment for your host platform according to the guide.
There are two main commands, flutter run to run the app or flutter build to build for the specified platform.
When using flutter run you can specify the mode in which the app will run. By default, it uses the debug mode.
# debug mode:
flutter run
# release mode:
flutter run --release
# profile mode:
flutter run --profileTo build the app, use flutter build followed by the build target.
As an example, for the mobile platforms:
# Android APK:
flutter build apk
# Android app bundle:
flutter build appbundle
# iOS IPA:
flutter build iosGoogle Chrome is required, and the chrome binary must be accessible by the flutter command (e.g. via the system path)
flutter clean
flutter pub getRun in debug mode:
flutter run -d chromeRun in release mode:
flutter run -d chrome --releaseRunning on web-server (useful for testing/debugging in different browsers):
flutter run -d web-server --web-port=8080In order to build for macOS, you need to use a macOS host.
Before you begin:
- Open
macos/Runner.xcworkspacein XCode - Set Product -> Destination -> Destination Architectures to 'Show Both'
flutter clean
flutter pub getDebug mode
flutter run -d macosIf you encounter build errors, try to follow any instructions in the error message.
In many cases, simply running the app from XCode before trying flutter run -d macos again will resolve the error.
- Open
macos/Runner.xcworkspacein XCode - Product -> Run
Release mode
flutter run -d macos --releaseBuild
flutter build macosIn order to build for Windows, you need to use a Windows host.
Run flutter config --enable-windows-desktop to enable Windows desktop support.
If you are using Windows 10, please ensure that Microsoft WebView2 Runtime is installed for Webview support. Windows 11 ships with it, but Windows 10 users might need to install it.
Before building for Windows, run flutter doctor to check if all the dependencies are installed. If not, follow the instructions in the error message.
flutter doctorflutter clean
flutter pub getDebug mode
flutter run -d windowsRelease mode
flutter run -d windows --releaseBuild
flutter build windowsIn order to build for Linux, you need to use a Linux host with support for libwebkit2gtk-4.1, i.e. Ubuntu 22.04 (jammy) or later.
Run flutter config --enable-linux-desktop to enable Linux desktop support.
Before building for Linux, run flutter doctor to check if all the dependencies are installed. If not, follow the instructions in the error message.
flutter doctorThe Linux dependencies, according to flutter.dev are as follow:
For Linux desktop development, you need the following in addition to the Flutter SDK:
- Clang
- CMake
- GTK development headers
- Ninja build
- pkg-config
- liblzma-dev (This might be necessary)
- libstdc++-12-dev
- webkit2gtk-4.1 (Webview support)
To install on Ubuntu 22.04 or later, run:
sudo apt-get install clang cmake ninja-build pkg-config libgtk-3-dev liblzma-dev libstdc++-12-dev webkit2gtk-4.1flutter clean
flutter pub getDebug mode
flutter run -d linuxRelease mode
flutter run -d linux --releaseBuild
flutter build linuxBuilding an app for Android and iOS requires you to download their respective IDEs and enable developer mode to build directly to the device.
However, iOS tooling only works on macOS host.
For Android, after installing the IDE and initial tools using the setup wizard, run the app with flutter run.
Flutter will attempt to build the app, and any missing Android SDK dependency will be downloaded.
Running the app on an Android emulator has been tested on Apple Silicon Macs only; for other host platforms, a physical device might be required.
flutter cleanflutter pub get- Activate developer mode and USB debugging on your device
- Connect your device to your computer with a USB cable
- Ensure Flutter is aware of your device by running
flutter devices - Copy your device ID
- Run in debug mode with
flutter run -d <device-id> - Follow instructions on your device
Release mode:
flutter run -d <device-id> --release
Build APK:
flutter build apk
Build App Bundle:
flutter build appbundle
In order to build for iOS/iPadOS, you need to use a macOS host (Apple silicon recommended) Physical iPhone or iPad required, simulators are not yet supported.
flutter cleanflutter pub get- Connect your device to your Mac with a USB cable
- Ensure Flutter is aware of your device by running
flutter devices - Copy your device ID
- Run in debug mode with
flutter run -d <device-id> - Follow the instructions in the error message (if any)
In many cases it's worth trying to run the app from XCode first, then run
flutter run -d <device-id>again- Open
ios/Runner.xcworkspacein XCode - Product -> Run
- Open
- Follow the instructions on your device to trust the developer
Run in release mode:
flutter run -d <device-id> --release
Build:
flutter build ios