Desktop support for Flutter

Flutter provides support for compiling a native Windows, macOS, or Linux desktop app. Flutter's desktop support also extends to plugins—you can install existing plugins that support the Windows, macOS, or Linux platforms, or you can create your own.

Create a new project

#

You can use the following steps to create a new project with desktop support.

Set up desktop devtools

#

Consult the guide for your target desktop environment:

If flutter doctor finds problems or missing components for a platform that you don't want to develop for, you can ignore those warnings. Or you can disable the platform altogether using the flutter config command, for example:

flutter config --no-enable-ios

Other available flags:

  • --no-enable-windows-desktop
  • --no-enable-linux-desktop
  • --no-enable-macos-desktop
  • --no-enable-web
  • --no-enable-android
  • --no-enable-ios

After enabling desktop support, restart your IDE so that it can detect the new device.

Create and run

#

Creating a new project with desktop support is no different than creating a new Flutter project for other platforms.

Once you've configured your environment for desktop support, you can create and run a desktop application either in the IDE or from the command line.

Using an IDE

#

After you've configured your environment to support desktop, make sure you restart the IDE if it was already running.

Create a new application in your IDE and it automatically creates iOS, Android, web, and desktop versions of your app. From the device pulldown, select windows (desktop), macOS (desktop), or linux (desktop) and run your application to see it launch on the desktop.

From the command line

#

To create a new application that includes desktop support (in addition to mobile and web support), run the following commands, substituting my_app with the name of your project:

flutter create my_app
cd my_app

To launch your application from the command line, enter one of the following commands from the top of the package:

C:\> flutter run -d windows
flutter run -d macos
flutter run -d linux

Build a release app

#

To generate a release build, run one of the following commands:

PS C:\> flutter build windows
flutter build macos
flutter build linux

Add desktop support to an existing Flutter app

#

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.

Plugin support

#

Flutter on the desktop supports using and creating plugins. To use a plugin that supports desktop, follow the steps for plugins in using packages. Flutter automatically adds the necessary native code to your project, as with any other platform.

Writing a plugin

#

When you start building your own plugins, you'll want to keep federation in mind. Federation is the ability to define several different packages, each targeted at a different set of platforms, brought together into a single plugin for ease of use by developers. For example, the Windows implementation of the url_launcher is really url_launcher_windows, but a Flutter developer can simply add the url_launcher package to their pubspec.yaml as a dependency and the build process pulls in the correct implementation based on the target platform. Federation is handy because different teams with different expertise can build plugin implementations for different platforms. You can add a new platform implementation to any endorsed federated plugin on pub.dev, so long as you coordinate this effort with the original plugin author.

For more information, including information about endorsed plugins, see the following resources:

Samples and codelabs

#
Write a Flutter desktop application
A codelab that walks you through building a desktop application that integrates the GitHub GraphQL API with your Flutter app.

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.

Wonderous app running app, repo
A showcase app that uses Flutter to create a highly expressive user interface. Wonderous focuses on delivering an accessible and high-quality user experience while including engaging interactions and novel animations. To run Wonderous as a desktop app, clone the project and follow the instructions provided in the README.
Flokk announcement blogpost, repo
A Google contacts manager that integrates with GitHub and Twitter. It syncs with your Google account, imports your contacts, and allows you to manage them.
Photo Search app
A sample application built as a desktop application that uses desktop-supported plugins.