Ubuntu Circle of Friends for web - (CC BY-SA 3.0) Copyright 2017 Canonical Ltd.

Flutter 2.0 on Ubuntu 21.04 is here!

"Flutter SDK snap build integration makes it easy to publish your multi-platform Flutter app for one-click install by millions of Linux desktop users." — So says the press release. Lets find out.

We've been working with Flutter for over two years now, creating Android and iOS apps from the same source code. With nearly 30 Flutter based apps in the App Store and Google Play. Flutter 2.0 adds Linux support and Ubuntu made a point of making it part of their Ubuntu 21.04 release. This is an indication of direction of travel. Flutter is capable of building robust mobile apps. The Linux support is new, but it is built on the same foundation. The promise of cross plaform app development is often mired in technical difficulties but this time there is something different in the level of industry collaboration and support for Flutter with some notable exceptions.

Hello, world on Ubuntu 21.04

Flutter 2.0 can now create Ubuntu 21.04 desktop apps, This is the hello world example app.

TL:DR— Getting this running too around a dozen commands, and a bit of default question answering in both Flutter and Android Studio, which you have to launch once its installed. It took about 15 minutes to set up.

$ sudo snap install flutter --classic
    $ flutter sdk-path
    $ export PATH="$PATH:/home/yourusernamehere/snap/flutter/common/flutter/bin"
    $ flutter config --no-analytics
    $ sudo snap install android-studio --classic
    $ flutter config --android-studio-dir /snap/android-studio/current/android-studio
    $ flutter doctor --android-licenses
    $ flutter config --enable-linux-desktop
    $ flutter doctor
    $ cd ~/Projects
    $ flutter create hello_world
    $ cd hello_world/
    $ flutter run -d linux

Step by Step instructions to install Flutter 2.0 on Ubuntu 21.04

  1. By far the easiest way to install Flutter is by using the snap. Snapd is part of Ubuntu 21.04. Type sudo snap install flutter --classic to install Flutter 2.0. "A snap is a bundle of an app and its dependencies that works without modification across Linux distributions.".
  2. Once installed type flutter sdk-pathand some configuration will take place and the command will tell you the path at which Flutter's binaries can be found. You need this.
  3. Make the path part of your environment, by adding the sdk-path to your .bashrcexport PATH="$PATH:/home/yourusernamehere/snap/flutter/common/flutter/bin"You'll need to restart your terminals or old school source it for this to take effect.
  4. Nobody likes being tracked, least of all by Google. You can turn it off.flutter config --no-analytics
  5. Use snap to install Android Studio too. Much easier than their Linux instructions.sudo snap install android-studio --classicOnce installed, find it using the system key and scrolling through your applications, complete first run setup, let if download all the things it needs, check for updates and then continue in the command line.
  6. Tell Flutter about Android Studio by typing flutter config --android-studio-dir /snap/android-studio/current/android-studio
  7. You'll need to accept the Android licenses to use Android Studio. Type flutter doctor --android-licensesand agree each one.
  8. Almost there. Flutter needs to be told to enable Linux support so type flutter config --enable-linux-desktop
  9. Check your confir using flutter doctorand of course fix any resulting issues.
  10. Navigate to your project folder or any folder you want to create your first app in. cd ~/Projects
  11. Use the create command to instantiate an app based on one of the example templates, type flutter create hello_world
  12. Change into its directory, cd hello_world/
  13. Run your first Linux app created in Flutter flutter run -d linux

Flutter Doctor housekeeping

Chrome warning

If you see a warning about Chrome, and you have Chromium installed, you can set an environment variable to tell flutter doctor how to find it export CHROME_EXECUTABLE=/snap/bin/chromium .

Multiple versions of Android Studio

If you see multiple versons of Android Studiom and you used the snap install method, you may have older versions lurking. snap keeps three versions of apps by default, and can chew up disk space. You can set snap to be more aggressive sudo snap set system refresh.retain=2 and remove offending verions snap remove android-studio --revision=revisionnumberhere. You'll need to find the revision number in the snap directory for the app concerned.

$ flutter doctor
$ Doctor summary (to see all details, run flutter doctor -v):

Flutter Devices output

I am used to seeing mobile devices here. It really is running in Ubuntu 21.04

$ flutter devices
    1 connected device:
    Linux (desktop) • linux • linux-x64 • Linux

Flutter developer tools

The comprehensive set of developer tools in Flutter is available in Ubuntu Linux. Hot Reload, and the Devtools make for an excellent environment for quickly seeing changes you make to your code.

Android Studio, looking at the Floating Action Button in hello_world On Ubuntu 21.04.
Flutter DevTools in Firefox looking at the Floating Action Button in hello_world on Ubuntu 21.04


Ubuntu Linux is available from Ubuntu downloads

About Snaps