To compile a desktop application, you must build it on the targeted platform: build a Windows application on Windows, a macOS application on macOS, and a Linux application on Linux.
To create a Flutter application with desktop support, you need the following software:
- Flutter SDK. See the Flutter SDK installation instructions.
- Optional: An IDE that supports Flutter. See setting up an editor for more details.
- Check if everything is set-up correctly as described here
When you create a new Flutter project you can indicate which platforms you want to support, by default chosen only Android and iOS, but you can enable all 6 platforms
After creating a project, you should run the following commands in a terminal from the root project directory:
flutter pub get
(This command gets all the dependencies listed in the pubspec.yaml file in the current working directory, as well as their transitive dependencies)- Run the Desktop application using the command:
flutter run
To add desktop support to an existing Flutter project, run the following command in a terminal from the root project directory:
flutter create --platforms=windows,macos,linux
This adds the necessary desktop files and directories to your existing Flutter project. To add only specific desktop platforms, change the platforms list to include only the platform(s) you want to add.
To generate a release build, run one of the following commands:
flutter build windows
flutter build macos
flutter build linux