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 --profile
To 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 ios
Google Chrome is required, and the chrome
binary must be accessible by the flutter command (e.g. via the system path)
flutter clean
flutter pub get
Run in debug mode:
flutter run -d chrome
Run in release mode:
flutter run -d chrome --release
Running on web-server (useful for testing/debugging in different browsers):
flutter run -d web-server --web-port=8080
In order to build for macOS, you need to use a macOS host.
Before you begin:
- Open
macos/Runner.xcworkspace
in XCode - Set Product -> Destination -> Destination Architectures to 'Show Both'
flutter clean
flutter pub get
Debug mode
flutter run -d macos
If 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.xcworkspace
in XCode - Product -> Run
Release mode
flutter run -d macos --release
Build
flutter build macos
In 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 doctor
flutter clean
flutter pub get
Debug mode
flutter run -d windows
Release mode
flutter run -d windows --release
Build
flutter build windows
In 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 doctor
The 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.1
flutter clean
flutter pub get
Debug mode
flutter run -d linux
Release mode
flutter run -d linux --release
Build
flutter build linux
Building 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 clean
flutter 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 clean
flutter 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.xcworkspace
in 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