DEV Community

Cover image for Set up a flutter development environment on Linux
Martin Klingenberg
Martin Klingenberg

Posted on

Set up a flutter development environment on Linux

Flutter has been on top of the list of technologies I should learn. I found the setup of a flutter development environment a bit segmented and wanted to make life easier for others wanting to jump into flutter development.

This guide is distro-agnostic but is only confirmed to work on fedora 38.

Install android studio

I have had mixed success installing editors as flatpaks. Download android studio and unpack the tar https://developer.android.com/studio. Move the android studio files to a safe place. I choose $HOME/.android-studio. You can then start android studio by running \~/.android-studio/bin/studio.sh. Install flutter-plugin an in my case the ideaVIM-plugin.

When you have opened android-studio and done the setup, you can add a desktop entry. By clicking tools/Create Desktop Entry

Desktop entry can easily be created

Install Command-line-tools

Install the command line tools. These will come in handy when we set up flutter. Can be done as easily as this

Step one of adding command line tools

Step two of adding command line tools

Fetch some dependencies

RHEL Distros (Fedora, RedHat, CentOS)

sudo dnf install clang cmake ninja-build pkgconf-pkg-config gtk3-devel lzma-sdk-devel
Enter fullscreen mode Exit fullscreen mode

Debian based distros (Ubuntu, Linux Mint etc)

sudo apt-get install clang cmake ninja-build pkg-config libgtk-3-dev liblzma-dev
Enter fullscreen mode Exit fullscreen mode

Download the morst recent SDK

I would avoid using snap on Fedora and rather download the SDK and install manually. It is quite easy. Find the latest stable version here https://docs.flutter.dev/get-started/install/linux.

Extract and install

Personally I would just install this as I set up golang, basically just adding a folder to your home-directory.

cd; tar xf ~/Downloads/flutter_linux_[VERSION]]-stable.tar.xz
Enter fullscreen mode Exit fullscreen mode

Update environment variables

If you use bash, execute the following to add flutter and android-commandline tools to the path

# IF YOU USE BASH
echo 'export PATH="$PATH:$HOME/flutter/bin"' >> $HOME/.bashrc
echo 'export PATH="$PATH:$HOME/Android/Sdk/cmdline-tools/latest/bin/"' >> $HOME/.bashrc

# IF YOU USE ZSH
echo 'export PATH="$PATH:$HOME/flutter/bin"' >> $HOME/.zshrc
echo 'export PATH="$PATH:$HOME/Android/Sdk/cmdline-tools/latest/bin/"' >> $HOME/.zshrc

# IF YOU USE FISH
echo 'set -xg PATH "$HOME/flutter/bin:$PATH"' >> $HOME/.config/fish/config.fish
echo 'set -xg PATH "$HOME/Android/Sdk/cmdline-tools/latest/bin:$PATH"' >> $HOME/.config/fish/config.fish
Enter fullscreen mode Exit fullscreen mode

Agree to stuff you do not understand

If you want to do this step properly you should hire a lawyer and pay him what ever it takes to have him explain the terms of agreeing to the licsense

flutter doctor --android-licenses
Enter fullscreen mode Exit fullscreen mode

And you are off to the races

Running the following command should give you an output looking like what I got below. And you should be able to launch your first app from android studio.

flutter doctor
Enter fullscreen mode Exit fullscreen mode

Successful installation of flutter

I am really not a big fan of big editors and this article might get updated with a guide setting up the android SDK manually and use Emacs / VsCode / VIM instead.

Top comments (1)

Collapse
 
naiveinvestigator profile image
NaiveInvestigator

For ppl who want to install the android SDK manually this post is super useful!

proandroiddev.com/how-to-setup-and...