How To Install Flutter On Ubuntu

In this tutorial, we will show you how to install Flutter on Ubuntu by using snapd. With Flutter, you can create natively compiled, multi-platform applications from a single codebase, which can be used on any device.

Prerequisites

Before you begin this guide you'll need the following:

  • A local development environment. You can check out the following tutorial here...

  • Installed Android Studio. You can check out the following tutorial here...

Step 1 — Install additional required packages for Linux development

Run the following command to update your current package index:

sudo apt-get install clang cmake ninja-build pkg-config libgtk-3-dev liblzma-dev

You'll see output similar to the following output:

Reading package lists... Done
Building dependency tree       
Reading state information... Done
The following additional packages will be installed:
  gir1.2-harfbuzz-0.0 icu-devtools libatk-bridge2.0-dev libatk1.0-dev libatspi2.0-dev libblkid-dev libcairo-script-interpreter2 libcairo2-dev libdatrie-dev libdbus-1-dev libegl-dev libegl1-mesa-dev
  libepoxy-dev libexpat1-dev libfontconfig1-dev libfreetype-dev libfreetype6-dev libfribidi-dev libgdk-pixbuf2.0-dev libgl-dev libgl1-mesa-dev libgles-dev libgles1 libglib2.0-dev libglib2.0-dev-bin
  libglvnd-dev libglx-dev libgraphite2-dev libharfbuzz-dev libharfbuzz-gobject0 libicu-dev libmount-dev libopengl-dev libpango1.0-dev libpcre16-3 libpcre2-dev libpcre2-posix2 libpcre3-dev libpcre32-3
  libpcrecpp0v5 libpixman-1-dev libpng-dev libpng-tools libselinux1-dev libsepol1-dev libthai-dev libwayland-bin libwayland-dev libxcb-render0-dev libxcb-shm0-dev libxcomposite-dev libxcursor-dev
  libxdamage-dev libxext-dev libxfixes-dev libxft-dev libxi-dev libxinerama-dev libxkbcommon-dev libxrandr-dev libxrender-dev libxtst-dev pango1.0-tools uuid-dev wayland-protocols x11proto-input-dev
  x11proto-randr-dev x11proto-record-dev x11proto-xext-dev x11proto-xinerama-dev zlib1g-dev
Suggested packages:
  libcairo2-doc libdatrie-doc freetype2-doc libgirepository1.0-dev libglib2.0-doc libgraphite2-utils libgtk-3-doc icu-doc libpango1.0-doc libthai-doc libwayland-doc libxext-doc
The following NEW packages will be installed:
  gir1.2-harfbuzz-0.0 icu-devtools libatk-bridge2.0-dev libatk1.0-dev libatspi2.0-dev libblkid-dev libcairo-script-interpreter2 libcairo2-dev libdatrie-dev libdbus-1-dev libegl-dev libegl1-mesa-dev
  libepoxy-dev libexpat1-dev libfontconfig1-dev libfreetype-dev libfreetype6-dev libfribidi-dev libgdk-pixbuf2.0-dev libgl-dev libgl1-mesa-dev libgles-dev libgles1 libglib2.0-dev libglib2.0-dev-bin
  libglvnd-dev libglx-dev libgraphite2-dev libgtk-3-dev libharfbuzz-dev libharfbuzz-gobject0 libicu-dev libmount-dev libopengl-dev libpango1.0-dev libpcre16-3 libpcre2-dev libpcre2-posix2 libpcre3-dev
  libpcre32-3 libpcrecpp0v5 libpixman-1-dev libpng-dev libpng-tools libselinux1-dev libsepol1-dev libthai-dev libwayland-bin libwayland-dev libxcb-render0-dev libxcb-shm0-dev libxcomposite-dev
  libxcursor-dev libxdamage-dev libxext-dev libxfixes-dev libxft-dev libxi-dev libxinerama-dev libxkbcommon-dev libxrandr-dev libxrender-dev libxtst-dev pango1.0-tools uuid-dev wayland-protocols
  x11proto-input-dev x11proto-randr-dev x11proto-record-dev x11proto-xext-dev x11proto-xinerama-dev zlib1g-dev
0 upgraded, 72 newly installed, 0 to remove and 0 not upgraded.
Need to get 19.6 MB of archives.
After this operation, 108 MB of additional disk space will be used.
Do you want to continue? [Y/n] Y
Get:1 http://archive.ubuntu.com/ubuntu focal-updates/main amd64 gir1.2-harfbuzz-0.0 amd64 2.6.4-1ubuntu4.2 [26.4 kB]
Get:2 http://archive.ubuntu.com/ubuntu focal-updates/main amd64 icu-devtools amd64 66.1-2ubuntu2.1 [189 kB]
Get:3 http://archive.ubuntu.com/ubuntu focal-updates/main amd64 libglib2.0-dev-bin amd64 2.64.6-1~ubuntu20.04.4 [109 kB]
Get:4 http://archive.ubuntu.com/ubuntu focal-updates/main amd64 uuid-dev amd64 2.34-0.1ubuntu9.3 [33.6 kB]
Get:5 http://archive.ubuntu.com/ubuntu focal-updates/main amd64 libblkid-dev amd64 2.34-0.1ubuntu9.3 [167 kB]
Get:6 http://archive.ubuntu.com/ubuntu focal-updates/main amd64 libmount-dev amd64 2.34-0.1ubuntu9.3 [176 kB]
Get:7 http://archive.ubuntu.com/ubuntu focal-updates/main amd64 libpcre16-3 amd64 2:8.39-12ubuntu0.1 [150 kB]
Get:8 http://archive.ubuntu.com/ubuntu focal-updates/main amd64 libpcre32-3 amd64 2:8.39-12ubuntu0.1 [140 kB]
Get:9 http://archive.ubuntu.com/ubuntu focal-updates/main amd64 libpcrecpp0v5 amd64 2:8.39-12ubuntu0.1 [15.5 kB]
Get:10 http://archive.ubuntu.com/ubuntu focal-updates/main amd64 libpcre3-dev amd64 2:8.39-12ubuntu0.1 [540 kB]
Get:11 http://archive.ubuntu.com/ubuntu focal-updates/main amd64 libsepol1-dev amd64 3.0-1ubuntu0.1 [325 kB]
Get:12 http://archive.ubuntu.com/ubuntu focal/main amd64 libpcre2-posix2 amd64 10.34-7 [5,992 B]
Get:13 http://archive.ubuntu.com/ubuntu focal/main amd64 libpcre2-dev amd64 10.34-7 [670 kB]
Get:14 http://archive.ubuntu.com/ubuntu focal/main amd64 libselinux1-dev amd64 3.0-1build2 [151 kB]
Get:15 http://archive.ubuntu.com/ubuntu focal-updates/main amd64 zlib1g-dev amd64 1:1.2.11.dfsg-2ubuntu1.3 [155 kB]
Get:16 http://archive.ubuntu.com/ubuntu focal-updates/main amd64 libglib2.0-dev amd64 2.64.6-1~ubuntu20.04.4 [1,506 kB]
Get:17 http://archive.ubuntu.com/ubuntu focal-updates/main amd64 libdbus-1-dev amd64 1.12.16-2ubuntu2.2 [167 kB]
Get:18 http://archive.ubuntu.com/ubuntu focal/main amd64 x11proto-xext-dev all 2019.2-1ubuntu1 [2,616 B]
Get:19 http://archive.ubuntu.com/ubuntu focal/main amd64 libxext-dev amd64 2:1.3.4-0ubuntu1 [82.2 kB]
Get:20 http://archive.ubuntu.com/ubuntu focal/main amd64 libxfixes-dev amd64 1:5.0.3-2 [11.4 kB]
Get:21 http://archive.ubuntu.com/ubuntu focal/main amd64 x11proto-input-dev all 2019.2-1ubuntu1 [2,628 B]
Get:22 http://archive.ubuntu.com/ubuntu focal/main amd64 libxi-dev amd64 2:1.7.10-0ubuntu1 [187 kB]
Get:23 http://archive.ubuntu.com/ubuntu focal/main amd64 x11proto-record-dev all 2019.2-1ubuntu1 [2,624 B]
Get:24 http://archive.ubuntu.com/ubuntu focal/main amd64 libxtst-dev amd64 2:1.2.3-1 [15.2 kB]
Get:25 http://archive.ubuntu.com/ubuntu focal/main amd64 libatspi2.0-dev amd64 2.36.0-2 [66.7 kB]
Get:26 http://archive.ubuntu.com/ubuntu focal-updates/main amd64 libatk-bridge2.0-dev amd64 2.34.2-0ubuntu2~20.04.1 [3,140 B]
Get:27 http://archive.ubuntu.com/ubuntu focal/main amd64 libatk1.0-dev amd64 2.35.1-1ubuntu2 [95.2 kB]
Get:28 http://archive.ubuntu.com/ubuntu focal/main amd64 libcairo-script-interpreter2 amd64 1.16.0-4ubuntu1 [54.2 kB]
Get:29 http://archive.ubuntu.com/ubuntu focal-updates/main amd64 libexpat1-dev amd64 2.2.9-1ubuntu0.4 [117 kB]
Get:30 http://archive.ubuntu.com/ubuntu focal/main amd64 libpng-dev amd64 1.6.37-2 [175 kB]
Get:31 http://archive.ubuntu.com/ubuntu focal-updates/main amd64 libfreetype-dev amd64 2.10.1-2ubuntu0.2 [493 kB]
Get:32 http://archive.ubuntu.com/ubuntu focal-updates/main amd64 libfreetype6-dev amd64 2.10.1-2ubuntu0.2 [9,812 B]
Get:33 http://archive.ubuntu.com/ubuntu focal/main amd64 libfontconfig1-dev amd64 2.13.1-2ubuntu3 [731 kB]
Get:34 http://archive.ubuntu.com/ubuntu focal/main amd64 libxrender-dev amd64 1:0.9.10-1 [24.9 kB]
Get:35 http://archive.ubuntu.com/ubuntu focal/main amd64 libpixman-1-dev amd64 0.38.4-0ubuntu1 [243 kB]
Get:36 http://archive.ubuntu.com/ubuntu focal/main amd64 libxcb-render0-dev amd64 1.14-2 [18.4 kB]
Get:37 http://archive.ubuntu.com/ubuntu focal/main amd64 libxcb-shm0-dev amd64 1.14-2 [6,716 B]
Get:38 http://archive.ubuntu.com/ubuntu focal/main amd64 libcairo2-dev amd64 1.16.0-4ubuntu1 [627 kB]
Get:39 http://archive.ubuntu.com/ubuntu focal/main amd64 libdatrie-dev amd64 0.2.12-3 [17.6 kB]
Get:40 http://archive.ubuntu.com/ubuntu focal-updates/main amd64 libglx-dev amd64 1.3.2-1~ubuntu0.20.04.2 [14.0 kB]
Get:41 http://archive.ubuntu.com/ubuntu focal-updates/main amd64 libgl-dev amd64 1.3.2-1~ubuntu0.20.04.2 [97.8 kB]
Get:42 http://archive.ubuntu.com/ubuntu focal-updates/main amd64 libegl-dev amd64 1.3.2-1~ubuntu0.20.04.2 [17.2 kB]
Get:43 http://archive.ubuntu.com/ubuntu focal-updates/main amd64 libgles1 amd64 1.3.2-1~ubuntu0.20.04.2 [10.3 kB]

Step 2 — Install the Flutter Package

Run the following command to update your current package index:

sudo snap install flutter --classic

You'll see output similar to the following output:

Downloading Linux x64 Dart SDK from Flutter engine e85ea0e79c6d894c120cda4ee8ee10fe6745e187...
  % Total    % Received % Xferd  Average Speed   Time    Time     Time  Current
                                 Dload  Upload   Total   Spent    Left  Speed

  0     0    0     0    0     0      0      0 --:--:-- --:--:-- --:--:--     0
  0  208M    0  1357    0     0   1627      0 37:16:24 --:--:-- 37:16:24  1625
  0  208M    0  389k    0     0   286k      0  0:12:25  0:00:01  0:12:24  286k
  1  208M    1 3390k    0     0  1436k      0  0:02:28  0:00:02  0:02:26 1436k
  3  208M    3 6798k    0     0  2022k      0  0:01:45  0:00:03  0:01:42 2022k
  4  208M    4  9.9M    0     0  2333k      0  0:01:31  0:00:04  0:01:27 2332k
  6  208M    6 13.2M    0     0  2540k      0  0:01:23  0:00:05  0:01:18 3007k
  7  208M    7 15.8M    0     0  2545k      0  0:01:23  0:00:06  0:01:17 3160k
  9  208M    9 19.0M    0     0  2645k      0  0:01:20  0:00:07  0:01:13 3216k
 10  208M   10 22.1M    0     0  2709k      0  0:01:18  0:00:08  0:01:10 3171k
 12  208M   12 25.5M    0     0  2797k      0  0:01:16  0:00:09  0:01:07 3203k
 13  208M   13 29.0M    0     0  2867k      0  0:01:14  0:00:10  0:01:04 3219k
 15  208M   15 32.4M    0     0  2927k      0  0:01:12  0:00:11  0:01:01 3414k
 16  208M   16 33.7M    0     0  2767k      0  0:01:17  0:00:12  0:01:05 2941k
 16  208M   16 35.0M    0     0  2689k      0  0:01:19  0:00:13  0:01:06 2656k
 17  208M   17 36.8M    0     0  2627k      0  0:01:21  0:00:14  0:01:07 2307k
 19  208M   19 39.9M    0     0  2666k      0  0:01:19  0:00:15  0:01:04 2249k
 20  208M   20 42.8M    0     0  2680k      0  0:01:19  0:00:16  0:01:03 2118k
 22  208M   22 46.2M    0     0  2725k      0  0:01:18  0:00:17  0:01:01 2616k
 23  208M   23 48.5M    0     0  2710k      0  0:01:18  0:00:18  0:01:00 2764k
 24  208M   24 51.5M    0     0  2725k      0  0:01:18  0:00:19  0:00:59 3008k
 26  208M   26 54.6M    0     0  2747k      0  0:01:17  0:00:20  0:00:57 2995k
 27  208M   27 57.7M    0     0  2767k      0  0:01:17  0:00:21  0:00:56 3052k
 28  208M   28 60.3M    0     0  2761k      0  0:01:17  0:00:22  0:00:55 2889k
 30  208M   30 63.5M    0     0  2786k      0  0:01:16  0:00:23  0:00:53 3068k
 31  208M   31 65.7M    0     0  2762k      0  0:01:17  0:00:24  0:00:53 2905k
 33  208M   33 69.0M    0     0  2789k      0  0:01:16  0:00:25  0:00:51 2960k
 34  208M   34 72.3M    0     0  2809k      0  0:01:15  0:00:26  0:00:49 2988k
 36  208M   36 75.6M    0     0  2832k      0  0:01:15  0:00:27  0:00:48 3149k
 37  208M   37 78.7M    0     0  2843k      0  0:01:14  0:00:28  0:00:46 3110k
 39  208M   39 82.1M    0     0  2864k      0  0:01:14  0:00:29  0:00:45 3363k
 41  208M   41 85.5M    0     0  2884k      0  0:01:13  0:00:30  0:00:43 3366k
 42  208M   42 88.3M    0     0  2886k      0  0:01:13  0:00:31  0:00:42 3289k
 43  208M   43 91.1M    0     0  2884k      0  0:01:13  0:00:32  0:00:41 3168k
 45  208M   45 94.3M    0     0  2895k      0  0:01:13  0:00:33  0:00:40 3190k
 46  208M   46 97.2M    0     0  2898k      0  0:01:13  0:00:34  0:00:39 3097k
 47  208M   47 99.7M    0     0  2887k      0  0:01:13  0:00:35  0:00:38 2908k
 49  208M   49  102M    0     0  2899k      0  0:01:13  0:00:36  0:00:37 2983k
 51  208M   51  106M    0     0  2913k      0  0:01:13  0:00:37  0:00:36 3100k
 52  208M   52  108M    0     0  2909k      0  0:01:13  0:00:38  0:00:35 3001k
 53  208M   53  111M    0     0  2908k      0  0:01:13  0:00:39  0:00:34 2976k
 55  208M   55  114M    0     0  2916k      0  0:01:13  0:00:40  0:00:33 3123k
 56  208M   56  117M    0     0  2920k      0  0:01:13  0:00:41  0:00:32 3070k
 57  208M   57  120M    0     0  2911k      0  0:01:13  0:00:42  0:00:31 2899k
 58  208M   58  121M    0     0  2871k      0  0:01:14  0:00:43  0:00:31 2580k
 59  208M   59  123M    0     0  2845k      0  0:01:14  0:00:44  0:00:30 2348k
 60  208M   60  125M    0     0  2830k      0  0:01:15  0:00:45  0:00:30 2137k
 61  208M   61  128M    0     0  2841k      0  0:01:15  0:00:46  0:00:29 2191k
 63  208M   63  131M    0     0  2848k      0  0:01:14  0:00:47  0:00:27 2315k
 64  208M   64  135M    0     0  2860k      0  0:01:14  0:00:48  0:00:26 2767k
 66  208M   66  138M    0     0  2869k      0  0:01:14  0:00:49  0:00:25 3081k
 67  208M   67  141M    0     0  2874k      0  0:01:14  0:00:50  0:00:24 3267k
 69  208M   69  143M    0     0  2869k      0  0:01:14  0:00:51  0:00:23 3123k
 70  208M   70  147M    0     0  2878k      0  0:01:14  0:00:52  0:00:22 3158k
 72  208M   72  150M    0     0  2884k      0  0:01:13  0:00:53  0:00:20 3116k
 73  208M   73  153M    0     0  2890k      0  0:01:13  0:00:54  0:00:19 3104k
 75  208M   75  156M    0     0  2899k      0  0:01:13  0:00:55  0:00:18 3155k
 76  208M   76  159M    0     0  2901k      0  0:01:13  0:00:56  0:00:17 3232k
 78  208M   78  162M    0     0  2909k      0  0:01:13  0:00:57  0:00:16 3235k
 79  208M   79  166M    0     0  2919k      0  0:01:13  0:00:58  0:00:15 3289k
 81  208M   81  169M    0     0  2928k      0  0:01:12  0:00:59  0:00:13 3337k
 83  208M   83  173M    0     0  2935k      0  0:01:12  0:01:00  0:00:12 3334k
 84  208M   84  175M    0     0  2932k      0  0:01:12  0:01:01  0:00:11 3286k
 85  208M   85  178M    0     0  2939k      0  0:01:12  0:01:02  0:00:10 3279k
 87  208M   87  182M    0     0  2945k      0  0:01:12  0:01:03  0:00:09 3244k
 88  208M   88  185M    0     0  2945k      0  0:01:12  0:01:04  0:00:08 3141k
 90  208M   90  188M    0     0  2946k      0  0:01:12  0:01:05  0:00:07 3078k
 91  208M   91  191M    0     0  2953k      0  0:01:12  0:01:06  0:00:06 3206k
 93  208M   93  194M    0     0  2950k      0  0:01:12  0:01:07  0:00:05 3094k
 94  208M   94  197M    0     0  2956k      0  0:01:12  0:01:08  0:00:04 3107k
 96  208M   96  200M    0     0  2962k      0  0:01:11  0:01:09  0:00:02 3185k
 97  208M   97  203M    0     0  2960k      0  0:01:12  0:01:10  0:00:02 3139k
 99  208M   99  206M    0     0  2964k      0  0:01:11  0:01:11 --:--:-- 3110k
100  208M  100  208M    0     0  2964k      0  0:01:11  0:01:11 --:--:-- 3173k
Building flutter tool...
Upgrading engine...
Downloading Material fonts...                                    1,398ms
Downloading Gradle Wrapper...                                       41ms
Downloading android-arm-profile/linux-x64 tools...               1,275ms
Downloading android-arm-release/linux-x64 tools...               1,100ms
Downloading android-arm64-profile/linux-x64 tools...             1,314ms
Downloading android-arm64-release/linux-x64 tools...             1,121ms
Downloading android-x64-profile/linux-x64 tools...               1,641ms
Downloading android-x64-release/linux-x64 tools...                 963ms
Downloading android-x86 tools...                                    4.3s
Downloading android-x64 tools...                                    4.0s
Downloading android-arm tools...                                    3.7s
Downloading android-arm-profile tools...                         2,720ms
Downloading android-arm-release tools...                         1,511ms
Downloading android-arm64 tools...                                  3.9s
Downloading android-arm64-profile tools...                       2,518ms
Downloading android-arm64-release tools...                       1,876ms
Downloading android-x64-profile tools...                         2,904ms
Downloading android-x64-release tools...                         1,806ms
Downloading android-x86-jit-release tools...                        3.0s
Downloading Web SDK...                                             12.9s
Downloading CanvasKit...                                            5.6s
Downloading package sky_engine...                                  430ms
Downloading flutter_patched_sdk tools...                         2,217ms
Downloading flutter_patched_sdk_product tools...                 1,409ms
Downloading linux-x64 tools...                                      9.8s
Downloading linux-x64/linux-x64-flutter-gtk tools...                4.9s
Downloading linux-x64-profile/linux-x64-flutter-gtk tools...         3.1s
Downloading linux-x64-release/linux-x64-flutter-gtk tools...         3.0s
Downloading linux-x64/font-subset tools...                         675ms

Step 3 — Run Flutter Doctor

In this step, we are going to make sure everything is set up correctly using flutter doctor.

 Run the following command to make sure everything is setup correctly:


flutter doctor -v

You'll see output similar to the following output:

[✓] Flutter (Channel stable, 3.0.5, on Ubuntu 20.04.4 LTS 5.4.0-122-generic, locale en_ZA.UTF-8)
    • Flutter version 3.0.5 at /opt/flutter
    • Upstream repository https://github.com/flutter/flutter.git
    • Framework revision f1875d570e (3 weeks ago), 2022-07-13 11:24:16 -0700
    • Engine revision e85ea0e79c
    • Dart version 2.17.6
    • DevTools version 2.12.2

[✓] Android toolchain - develop for Android devices (Android SDK version 30.0.3)
    • Android SDK at /home/sheldona/Android/Sdk
    • Platform android-32, build-tools 30.0.3
    • Java binary at: /snap/android-studio/123/android-studio/jre/bin/java
    • Java version OpenJDK Runtime Environment (build 11.0.12+0-b1504.28-7817840)
    • All Android licenses accepted.

[✓] Chrome - develop for the web
    • Chrome at google-chrome

[✓] Linux toolchain - develop for Linux desktop
    • clang version 10.0.0-4ubuntu1
    • cmake version 3.16.3
    • ninja version 1.10.0
    • pkg-config version 0.29.1

[✓] Android Studio (version 3.5)
    • Android Studio at /opt/android-studio
    • Flutter plugin can be installed from:
      🔨 https://plugins.jetbrains.com/plugin/9212-flutter
    • Dart plugin can be installed from:
      🔨 https://plugins.jetbrains.com/plugin/6351-dart
    • Java version OpenJDK Runtime Environment (build 1.8.0_202-release-1483-b49-5587405)

[✓] Android Studio (version 2021.2)
    • Android Studio at /snap/android-studio/123/android-studio
    • Flutter plugin version 69.0.2
    • Dart plugin version 212.5744
    • Java version OpenJDK Runtime Environment (build 11.0.12+0-b1504.28-7817840)

[✓] VS Code
    • VS Code at /snap/code/current
    • Flutter extension can be installed from:
      🔨 https://marketplace.visualstudio.com/items?itemName=Dart-Code.flutter

[✓] Connected device (2 available)
    • Linux (desktop) • linux  • linux-x64      • Ubuntu 20.04.4 LTS 5.4.0-122-generic
    • Chrome (web)    • chrome • web-javascript • Google Chrome 103.0.5060.134

[✓] HTTP Host Availability
    • All required HTTP hosts are available

• No issues found!

Step 4 - Accept Android Licenses

In this step, we are going to accept Android licenses


flutter doctor --android-licenses

If prompted, press the Y key followed by enter to accept each license it presents.

Step 5 — Developing projects for Linux

In order to develop Flutter projects for Linux, you must update the dev branch of Flutter and enable the toolchain

 Run the following command to switch to the dev branch


flutter channel dev

Run the following command to update Flutter to the latest dev branch revision:


flutter upgrade

Run the following command to enable the Linux toolchain


flutter config --enable-linux-desktop

Conclusion

In this article, you should have installed Flutter and verified your installation.

Comments