Setup Flutter

How to setup Flutter on Linux

3 min read
Last update: November 28, 2021

Flutter Official Flutter website

You need to install **Android Studio** before install **Flutter**, follow [**this guide**](/guides/flutter/android-studio/)

1. Installation

Example to download with terminal with Flutter v1.22.4, check official website to download last version. But you can download this version and upgrade Flutter after with flutter upgrade

wget -O flutter_linux_1.22.4-stable.tar.xz ""
mv flutter_linux*.tar.xz ~/Android ; tar xf ~/Android/flutter_linux*.tar.xz ~/Android

Add this .profile, .bashrc or .zshrc

export PATH="$PATH:/home/$USER/Android/flutter/bin"
source ~/.zshrc

Multiple versions

If you want to use multiple versions of Flutter, you can use FVM, check this guide : Flutter: multiples versions

2. Setup

flutter doctor

You will see some infos about Flutter setup

Android licenses

If you see this

Some Android licenses not accepted.  To resolve this, run: flutter doctor

Execute follow command to accept all licenses

flutter doctor --android-licenses

Accept all licenses.

Android Studio

If you see this

[!] Android Studio (version 4.0)
    ✗ Flutter plugin not installed; this adds Flutter specific functionality.
    ✗ Dart plugin not installed; this adds Dart specific functionality.

Find Plugins with double tape on N Download plugin Flutter on Android Studio (accept Dart plugin to be installed)

Visual Studio Code Download Flutter and Dart extensions for Visual Studio Code
Connected device
[!] Connected device
    ! No devices available

Start emulator from AVD Manager in Android Studio (you can close Android Studio after this), you can also connect a Android smartphone to your computer, Flutter can check it too. If Flutter can't, check if phone is detected with adb devices. If this command don't see your phone, try another cable or phone.

Run flutter doctor to check if evrything is okay

3. Create a new app

Respect CamelCase for app name

flutter create myApp ; cd myApp

Download all Java dependencies to execute app, this will take long time at the first execution.

flutter run

From VSCode

In Debug tab, create Flutter & Dart launch config if not exist Accept to always open Dart DevTools

You need to install Google Chrome

sudo sh -c 'echo "deb [arch=amd64] stable main" > /etc/apt/sources.list.d/google-chrome.list' ; wget -q -O - | sudo apt-key add - ; sudo apt-get update
sudo apt install -y google-chrome-stable

With CLI

With this command, flutter run will run app with DevTools, you can access to it with an generated URL after run

flutter pub global activate devtools

May crash if flutter run take already the DevTools port

flutter pub global run devtools

4. Upgrade

flutter upgrade # or flutter upgrade --force

5. Snap on Ubuntu

I advice you to NOT install Flutter with snap, you will have PATH problems, even it's the official setup offer by FLutter documentation.

sudo snap install flutter --classic

Add to .zshrc

export PATH="/snap/bin:$PATH"
sudo apt-add-repository ppa:maarten-fonville/android-studio
sudo apt-get update
sudo apt-get install android-studio
  • Execute Android Studio, setup it with default options
  • Hardware acceleration for emulator :
  • Download dependencies
  • Create new default project
  • Open AVD manager (double shift and research)
  • Create new phone : Pixel 2 with Oreo 8.1 (with Play store)
  • Download Android system image
flutter doctor --android-licenses