Set up a flutter development environment on Linux
Tags: flutter, development, tutorial, linux
Published: 2023-04-30 11:15:11



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](https://dev-to-uploads.s3.amazonaws.com/uploads/articles/xpcqwlokvxfyub3o8bk4.png)

### 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](https://dev-to-uploads.s3.amazonaws.com/uploads/articles/u4r1f8hbjfze6qer1cvc.png)
    
![Step two of adding command line tools](https://dev-to-uploads.s3.amazonaws.com/uploads/articles/s71xy4fytqk3hkiezo1d.png)

## Fetch some dependencies

### RHEL Distros (Fedora, RedHat, CentOS)

```bash
sudo dnf install clang cmake ninja-build pkgconf-pkg-config gtk3-devel lzma-sdk-devel
```

### Debian based distros (Ubuntu, Linux Mint etc)

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

## 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.

```bash
cd; tar xf ~/Downloads/flutter_linux_[VERSION]]-stable.tar.xz
```

## Update environment variables

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

```bash
# 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
```

## 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

```bash
flutter doctor --android-licenses
```

## 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.

```bash
flutter doctor
```
![Successful installation of flutter](https://dev-to-uploads.s3.amazonaws.com/uploads/articles/v9bj7u2g221yxwkea5eo.png)

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.