Flutter
Published in

Flutter

Canonical enables Linux desktop app support with Flutter

The Ubuntu team has produced a new GTK+ based host for Flutter apps on all Linux distros

Why Flutter for Linux?

Last year, when Google announced desktop-class application support with Flutter, Canonical saw an exciting opportunity to make Linux distributions, including Ubuntu, an attractive target platform for Flutter app developers. Flutter’s native cross-platform story is growing rapidly and Canonical wanted to be at the vanguard. By enabling desktop Linux support in Flutter, Canonical is making it very easy for application developers to publish their apps for Linux users via the Snap Store, the app store for Linux. By making Linux a first-class Flutter platform, Canonical is inviting application developers to publish their apps to millions of Linux users and broaden the availability of high quality applications available to them.

  • Fast growing ecosystem of application developers
  • Multiple platform support
  • Highly optimized native applications
  • Modern UI framework supporting declarative, reactive, and composable widgets
  • Rich development platform using Visual Studio Code, Android Studio, and IntelliJ

Flokk: Proving Flutter’s readiness for the desktop

To demonstrate that Flutter was ready for the desktop, we worked with the designers and developers at gskinner to create an innovative, beautiful Flutter desktop app. Flokk is a real-world app that works with real-world data, specifically your Google Contacts list.

The Flokk Contacts app was built with Flutter to target the desktop
Flutter enables Flokk to take advantage of smooth animation, high-performance scrolling, and easy theming

Easy install of Flutter on Linux

Now that you’ve seen how well Flutter works for desktop-class applications, especially on Linux, you’re going to want to get it running on your own Linux machine. To make that as simple as possible, we’re pleased to provide the Flutter SDK for Linux as a snap in the Snap Store. The Flutter SDK snap provides everything needed to develop Flutter apps on your favorite Linux distribution. No need to install a bunch of development dependencies; simply install the Flutter SDK snap and your favorite IDE, and you have everything you need to create, build, and publish your applications for Linux.

$ snap install --classic flutter
$ snap install --classic code
$ code --install-extension dart-code.flutter

Flutter for Linux desktop

Once the Flutter SDK is installed on your Linux machine, to build a desktop app you need to upgrade to the Flutter dev or master channel. Then enable Linux desktop support:

$ flutter channel dev
$ flutter upgrade
$ flutter config --enable-linux-desktop
$ flutter create counter
$ cd counter
$ flutter run -d linux
The famous Flutter Counter app runs great on Linux, too
$ cd my_flutter_app
$ flutter create .

Accessing native code in Linux from Flutter

In addition to supporting the desktop by writing Dart to create Flutter widgets, your Linux desktop apps can also access all of native Linux using platform channels or the Dart Foreign Function Interface for C/C++. Or, if you’d like to reuse pre-existing code, you can find that code on pub.dev, Dart and Flutter’s package manager site. Most of the packages you’ll find on pub.dev are pure Dart, most of which work just fine in Linux apps. Some packages, called plugins, have native code in them that are specific to one or more platforms. As part of this release, we’ve published three plugins on pub.dev that use native functionality of Linux:

  • url_launcher: launch the default browser at a URL provided
  • shared_preferences: user preferences shared between app sessions
  • path_provider: path information about special-purpose directories, such as downloads, pictures, and so on

Deploying to the Snap Store

To deploy your Flutter app to the Snap Store, you first need to install Snapcraft, the tool that you’ll use to build and publish your application as a snap:

$ sudo snap install snapcraft --classic
name: flokk-contacts
version: 1.0.1
summary: Flokk Contacts
description: A fresh and modern Google Contacts manager that integrates with GitHub and Twitter.
confinement: strict
base: core18
grade: stable
apps:
flokk-contacts:
command: flokk-contacts
extensions: [flutter-master]
plugs:
- network
parts:
flokk-contacts:
source: .
plugin: flutter
flutter-target: lib/main.dart # app's main entry-point file
$ snapcraft
$ snapcraft login
$ snapcraft register flokk-contacts
$ snapcraft upload flokk-contacts_1.0.1_amd64.snap --release edge
$ snap install --edge flokk-contacts

Flutter Linux desktop samples

The Flokk app is an excellent example of a real-world Flutter app targeting the Linux desktop. For a simpler sample, you can check out the Photo Search app, which was also built specifically to show off desktop features.

Try the Photo Search sample on Linux
The Flutter GitHub codelab client application in action
The Flutter Gallery sample is available on the Snap Store
Play in real time across multiple Flutter platforms

Summary

With this alpha release and the close partnership between Google and Canonical, Linux developers get Flutter support for their operating system of choice. Install the Flutter SDK via snap. Build and test your desktop app on Linux using Visual Studio Code or Android Studio. Deploy your app to the Snap Store. For the latest details, see the desktop page on flutter.dev. And above all else, make sure to provide feedback so that we can continue making Flutter the best it can be on Linux, as we strive to do for every supported Flutter platform.

--

--

Get the Medium app

A button that says 'Download on the App Store', and if clicked it will lead you to the iOS App store
A button that says 'Get it on, Google Play', and if clicked it will lead you to the Google Play store
Chris Sells

Chris Sells has a long history as a contributing member of the Windows developer community. He enjoys long walks on the beach and various computer technologies.