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
- 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.".
- 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.
- 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.
- Nobody likes being tracked, least of all by Google. You can turn it off.flutter config --no-analytics
- 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.
- Tell Flutter about Android Studio by typing flutter config --android-studio-dir /snap/android-studio/current/android-studio
- You'll need to accept the Android licenses to use Android Studio. Type flutter doctor --android-licensesand agree each one.
- Almost there. Flutter needs to be told to enable Linux support so type flutter config --enable-linux-desktop
- Check your confir using flutter doctorand of course fix any resulting issues.
- Navigate to your project folder or any folder you want to create your first app in. cd ~/Projects
- Use the
createcommand to instantiate an app based on one of the example templates, type flutter create hello_world
- Change into its directory, cd hello_world/
- Run your first Linux app created in Flutter flutter run -d linux
Flutter Doctor housekeeping
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.
Ubuntu 21.04 is available from Ubuntu downloads.Snap support is built in.
Android Studio information is available from developer.android.com. But you should install it from the snap as shown above.
You can find out about snap atAbout Snaps.