Desktop support for Flutter

With desktop support, you can compile Flutter source code to a native macOS Desktop app. Flutter’s desktop support also extends to plugins—you can install existing plugins that support the macOS platform, or you can create your own.

This page covers desktop support for macOS which is available as an alpha release as of 1.13. This page does not cover Windows or Linux platforms, which are in technical preview. You can try Windows and Linux platform support by reading the Desktop shells page in the Flutter wiki.

Requirements

To create a Flutter app with desktop support, you need the following software:

Set up

You must be on the master flutter build release channel and enable the macOS desktop platform feature:

$ flutter channel master
$ flutter upgrade
$ flutter config --enable-macos-desktop

Create and run

Create and/or navigate to the directory for your new project using the following commands. Replace myapp with the name you would like to use for your project.

$ mkdir myapp
$ cd myapp

Once you have navigated to your root project directory, use the following commands to create and run the Flutter starter app as a new desktop project:

$ flutter create .
$ flutter run -d macOS

Desktop Hello World

Flutter’s desktop support includes the create and build commands as well as the run command with debug mode, release mode, profile mode, and hot reload.

Build

To generate a release build run the following command:

$ flutter build macos

Add desktop support to an existing Flutter project

To add desktop support to an existing project, run the following command in a terminal from the root project directory:

$ flutter create .

To run your project as a desktop app, use the following command:

$ flutter run -d macOS

IDE Support

You can create, run, and debug a Flutter project with desktop support using the existing Dart and Flutter extensions for Android Studio and IntelliJ as well as Visual Studio Code. Follow the instructions to set up an editor and install the Dart and Flutter extensions (also referred to as editor plugins).

VS Code: Create and run a new project with desktop support

Creating a new project with desktop support is no different than creating a new Flutter project for other platforms. Running a Flutter desktop app is no different than running and debugging in VS Code for other target platforms:

  1. Select macOS as a target device from the VS Code status bar.
  2. Click the Debug > Start Without Debugging or press F5.

Desktop VS Code

Android Studio and IntelliJ IDEA: Create and run a new project with desktop support

Creating a new project with desktop support is no different than creating a new Flutter project for other platforms. To run a Flutter project with desktop support, use the same process for [running and debugging Flutter projects in Android Studio and IntelliJ] with other target platforms:

  1. Select macOS (desktop) from the target selector dropdown menu in the Flutter extension toolbar.
  2. Click the Play icon in the toolbar, or invoke Run > Run.

Desktop IntelliJ

Plugin support

Flutter Desktop supports both using and creating plugins.

To use a plugin that supports macOS, follow the steps for plugins in using packages. Flutter automatically adds the necessary native code to your project, as with iOS or Android.

  1. Add the latest version of the plugin to pubspec.yaml.
  2. Run flutter pub get.
  3. Run flutter run.

The following plugins have macos desktop support:

Creating plugins

To create a plugin with desktop support you should use the following resources:

Samples

You can run the following samples as desktop apps, as well as download and inspect the source code to learn more about Flutter desktop support.

Flutter Gallery
A samples project hosted on GitHub to help developers evaluate and use Flutter. The Gallery consists of a collection of material design widgets, behaviors, and vignettes implemented with Flutter. You can clone the project and run Gallery as a desktop app by following the provided instructions in the README.
Photo Search app
A sample app built as a desktop application that uses the following desktop-specific plugins:
  • file_chooser
  • menubar
  • url_launcher

What’s next

Stay tuned for updates on desktop support! We will continue to develop desktop support for Mac, Windows, and Linux.