Codemagic has great expertise in Flutter and we are committed to supporting Flutter and their vision to create a portable UI toolkit that extends to any screen. Flutter took the first major step towards going beyond mobile when they released the developer preview of Flutter for web at Google I/O in May 2019. Now at GDD China, the Flutter team announced that they had successfully integrated Flutter's web support into the main Flutter repository, which marks yet another milestone down that road.

In anticipation of the next big step which will further extend Flutter apps to desktop, we have made building desktop apps available on Codemagic. Developers can now build Flutter desktop apps for macOS and Linux using Codemagic. Watch a short demo of building and installing a macOS app below!

Creating desktop apps

Everything you need to create and run Flutter desktop apps is in the flutter/* repositories. The only thing at this point that's not in flutter/* is the prototype runners in google/flutter-desktop-embedding, which are only needed for setting up a project to have desktop support. Building a project that already has a compatible {macos/windows/linux} directory is done using a completely standard Flutter checkout.

Flutter GitHub wiki on desktop shells has more details on how to set up your local environment to create and build a Flutter desktop app.

Building desktop apps on Codemagic

To build desktop apps on Codemagic, go to your app settings and navigate to build settings. Here you can specify the Flutter version to use. Flutter for desktop is available on master channel. Select the platforms you are targeting and start building.

Pro tip: You can separate platforms into different workflows to speed up your builds.

Once you save the settings and start a build, Codemagic will build the desktop apps without code signing and export the artifacts as downloadable zip files. Support for code signing will follow soon.

You can distribute the apps via Slack or email and install them on local machines. Slack and email publishing can be configured in the Publish section of the app settings.

Now watch this short demo of building a desktop app on macOS and installing and running it on a mac.

Flutter Desktop stability

From the Flutter wiki on desktop shells, it reads that macOS can be expected to be quite stable.

“This is the most mature of the desktop platforms (for various reasons, including that it's quite close to iOS, which we already support). The Objective-C API layer is largely stable at this point, so breaking changes there should be rare.”

Windows and Linux, however, are currently not as stable as macOS.

“The current Linux shell is a GLFW placeholder, to allow early experimentation. We would like to create a library that lets you embed Flutter regardless of whether you're using GTK+, Qt, wxWidgets, Motif, or another arbitrary toolkit for other parts of your application, but have not yet determined a good way to do that. Our current plan is to support GTK+ out of the box, in a way where adding support for other toolkits is straightforward. Expect the APIs for the final shell to be radically different from the current implementation.”

Changes to Linux runners may not be backwards compatible and changes may occur within the same Flutter version, which can lead to situations where developers need to specify a commit hash in addition to the specific Flutter version they are trying to use on Codemagic.

To help you with this, you can use a post-clone script to check out a Flutter version with a specific commit hash.

#!/bin/sh set -ex cd ~/programs/flutter git checkout <commit_hash> flutter --version

What's next?

We will continue to work on Flutter Desktop. As next steps, we will add code signing for desktop apps and support for Windows apps as well. Keep an eye on our release notes or join our Slack community to stay updated with Codemagic feature releases.