The first step to develop Flutter desktop applications is to configure Flutter to use the dev
channel because Flutter for desktop is still under development. You also need to configure desktop support as a one-time configuration setup.
Dec 11, 2019 Developers have long been able to use their Mac machines to create Android and iOS apps with Flutter, and starting with today’s Flutter 1.12 release, it’s now possible to create apps directly. MacOS supports developing Flutter apps in iOS, Android, and the web (technical preview release). Complete at least one of the platform setup steps now, to be able to build and run your first Flutter app. IOS setup Install Xcode. To develop Flutter apps for iOS, you need a Mac with Xcode installed.
To confirm that Flutter for desktop is enabled, run the following command.
If you do not see the macOS line shown in the preceding output, consider the following:
flutter config
list macOS as enabled with enable-macos-desktop: true
?flutter channel
list either dev
or master
as the current channel? This is required as the code will not run on the stable
or beta
channels.If you do not see the Linux line shown in the preceding output, consider the following:
flutter config
list Linux as enabled with enable-linux-desktop: true
?flutter channel
list either dev
or master
as the current channel? This is required as the code will not run on the stable
or beta
channels.An easy way to get started writing Flutter for desktop apps is to use the Flutter command-line tool to create a Flutter project. Alternatively, your IDE may provide a workflow for creating a Flutter project through its UI.
For the purpose of simplifying this codelab, delete the Android, iOS, and web support files. These files are not required for Flutter for a macOS or Linux desktop application. Deleting the files helps to eliminate accidentally running the wrong variant during this codelab.
To make sure everything is working, run the boilerplate Flutter application as a macOS or Linux desktop application as shown below. Alternatively, open this project in your IDE, and use its tooling to run the application. Thanks to the previous step, running as a macOS or Linux application should be the only available option.
You should now see the following application window on your screen. Go ahead and click the floating action button to make sure that the incrementer works as expected. You can also try hot reload by changing the theme color by or altering the behavior of the _incrementCounter
method in lib/main.dart
.
Here is the application running on macOS.
Here it is again, this time on Linux.
In the next section you'll authenticate on GitHub using OAuth2.