Flutter for Desktop: Complete Linux Installation Guide.

Abhishek Kumar
Code for Cause
Published in
4 min readJun 13, 2020

A random conversation:
“ What flutter is for:
Flutter for Android
Flutter for iOS
Flutter for Web
Flutter for MacOS
Flutter for Windows
Flutter for Linux
Yes! Flutter is having something for …

In the world of diversity, flutter speaks a single language of unity. Once we setup our development environment for the platform, we are ready to build anything on any platform using a single framework that everyone knows with the name of flutter.

So let's start with installing flutter for Desktop on Linux.

Before you start it is assumed that the flutter is installed and configured for Android on your device, if not you can head over to here.

Since flutter for Desktop for Windows and Linux is still under development, you can not setup your environment with its stable release… and you can expect some really big changes with the flutter API.
But for now what to do:
Fire-up the terminal and be ready to develop your first fantastic application with flutter.

$ flutter channelFlutter channels:
master
dev
beta
* stable
$ flutter channel master && flutter upgradeSuccessfully switched to flutter channel 'master'.
upgrading flutter...

Now you have switched to master branch of flutter github repo. Now you can enable flutter development tools for Linux or Windows or both.
To enable flutter Linux features run:

$ flutter config --enable-linux-desktop

Now run flutter devices and you should see:

$ flutter devices
1 connected device:
Linux • Linux • linux-x64 • Linux$ # Now you have successfully configured your device config.

Now run flutter doctor:

$ flutter doctor

You may get errors in your Linux toolchain and require to install the required apt-packages.

$ sudo apt install 1st 2nd 3rd
# replace the numbers with the packages thrown by flutter doctor

Now flutter requires other dependencies and packages to be installed to run your development environment. You need to install those by:

$ sudo apt-get install cmake libgtk-3-dev pkg-config

This installs cmake to manage the build processes, libgtk-3-dev for widget-toolkits development and pkg-config for package-configurations. At this point, you have configured all the global requirements to setup our Linux development environment, now reassure that you don't have any errors with flutter doctor.
Now its time to create your first application:

$ flutter create myFirstDesktopApp
$ cd myFirstDesktopApp

It creates your application with the name myFirstDesktopApp and you can now open your app in your favorite code editor.

Now when you run flutter run you may still get cmake errors:

This is because we need to download platform-specific development binaries and build tools beforehand. To download such:

$ flutter precache --linux

Now its time to setup your pubspec.yaml file. We are basically adding desktop development plugins for flutter. Currently, they are less in numbers but enough to build your desired application.

dependencies:
flutter:
sdk: flutter
file_chooser:
git:
url: git://github.com/google/flutter-desktop-embedding.git
path: plugins/file_chooser
ref: 5d227793a515c822d634587b230601a31921ef6a # DummyID May ...Not be latest

With this process, our app knows that we are embedding desktop builds.
ref: is the latest commit Id of the flutter-desktop-embedding.git repo. To get the Latest Commit, go to the repo and get the latest commit hash by clicking on the latest commit and copying the full hash Id either from the page or the browser’s address bar.

And guess what! Its the end of all your setups and start of your development journey.

$ flutter pub get$ flutter run

That’s it now you have successfully configured your environment and created your first app with it. If you like this article give a handful of clap and share with other flappy birds.

--

--

Abhishek Kumar
Code for Cause

Loves Flutter, Java, Web, Mobile | opensource @checkstyle_java | Student at MAIT