Bring your multi-platform apps to Linux desktop with Flutter 3
by Oliver Smith on 18 May 2022
Google I/O 2022 took place last week and brought with it a host of exciting news from the world of Google, including the announcement of Flutter 3 with long-awaited Linux Desktop support!
Flutter 3 is the next big step in Flutter’s journey to enable multi-platform application development across what is now six platforms: iOS, Android, Web, Windows, macOS and Linux. It features improved performance and additional profiling in Flutter DevTools, support for Material 3, Apple silicon, accessibility services and web app life-cycles on top of the snazzy new Flutter Casual Games Toolkit and much more
There’s truly something for everyone in this latest release.
Linux Desktop support is production-ready
Canonical and the Flutter team have partnered closely to bring desktop support to Linux. We’ve created packages that allow for deep integration with system services like dbus, gsettings, desktop notifications and network manager, enabling everything you need to deliver a high-quality desktop experience. You can even style your app with Ubuntu’s iconic Yaru theme.
As of this week, Linux desktop support has moved to stable, meaning it’s production-ready and enabled immediately once you create a new application.
You can check this by running ‘flutter doctor’ and looking for the following in the output.
[✓] Linux toolchain - develop for Linux desktop
To run your application on Linux, simply type ‘flutter run -d linux’ from the command line.
To build it, it is as easy as ‘flutter build linux’.
In addition, if you have an existing Flutter project that you’d like to bring to Linux, all you need to do is run the following command from the root project directory:
flutter create --platforms=linux
And then the above commands will become available.
You can find more information on developing for desktop OSs here.
Easy authentication with FlutterFire Auth
But that’s not all, our colleagues at Invertase have also got some exciting news, with FlutterFire Auth also moving to stable. FlutterFire connects your desktop app to Google’s Firebase services and FlutterFire Auth enables developers on Windows and Linux to authenticate their app via email, phone number or various OAuth providers such as Google and GitHub.
To add FlutterFire Auth support to your project, simply run the following commands in your project root folder:
flutter pub add firebase_core_desktop
flutter pub add firebase_auth_desktop
You can also add it to your existing project with:
flutter pub add firebase_core
flutter pub add firebase_auth
For more details on how to take advantage of FlutterFire Auth, check out Invertase’s latest blog.
For more information on Invertase’s future plans for FlutterFire, you can follow their 2022 roadmap on their GitHub here.
Bring your Flutter desktop app to the Snap Store
So you’ve got a great Flutter app and you’ve built it for Linux. The next step is to get it in front of users!
The Snap store is available on any Linux distribution running snapd and delivers a range of cutting edge development tools and key productivity apps to millions of users all over the world. From IDEs like VS Code and Android Studio to messaging apps like Telegram, Discord and Slack as well as tools for creators like Blender, Shotcut and OBS Studio. We’ve even got gamers covered with our new Steam snap.
Snaps are sandboxed, easily updated and bundle all the dependencies your apps need to run across a range of Linux distributions. Packaging your Flutter app as a snap is simple and the Flutter docs have a simple how-to guide to get you started.
Once you’ve published your snap, let us know in the snapcraft forum or the Ubuntu Desktop discourse where many community members are already experimenting with Flutter on Linux!
Explore Flutter 3
Everything we’ve talked about in this post is just the tip of the iceberg when it comes to the latest release of Flutter. To learn more, check out the official Flutter I/O page for a comprehensive breakdown of its new features along with a range of helpful talks and tutorials to help developers get the most out of this versatile toolset!
At Canonical we’re looking forward to welcoming a whole new community of Flutter developers to the wonderful world of Linux. It’s great to have you here!