Installing Flutter on Linux

This guide assumes you are using the Fish shell.

Step 1: Clone the Flutter Repository

Flutter is available on GitHub. To install it, clone the official repository:

git clone https://github.com/flutter/flutter.git ~/flutter

This command downloads Flutter into the ~/flutter directory. You can change this path if needed.

Step 2: Add Flutter to Your PATH

To use Flutter globally, add it to your system PATH using Fish shell:

fish_add_path ~/flutter/bin

To make this change persistent, add it to your Fish configuration file:

echo 'fish_add_path ~/flutter/bin' >> ~/.config/fish/config.fish

Step 3: Verify Installation with Flutter Doctor

Run the following command to check for any missing dependencies:

flutter doctor

This command will analyze your system and list any missing dependencies needed for Flutter development.

If you see issues like missing Android SDK or GTK 3.0 development libraries, follow the steps below to fix them.

Step 4: Install Dependencies

Ensure you have the necessary dependencies installed:

sudo apt update && sudo apt install -y curl unzip xz-utils libglu1-mesa clang cmake ninja-build pkg-config libgtk-3-dev

For Arch Linux:

sudo pacman -S --needed curl unzip xz clang cmake ninja pkg-config gtk3

For Fedora:

sudo dnf install -y curl unzip xz clang cmake ninja-build pkg-config gtk3-devel

If flutter doctor reports missing GTK 3.0 development libraries, ensure they are installed:

Step 5: Install Android SDK Using Android Studio

If flutter doctor reports that the Android SDK is missing, follow these steps to install Android Studio:

  1. Download Android Studio from the official website: Android Studio Download
  2. Extract the downloaded .tar.gz file: mkdir ~/android-studio && tar -xvf ~/Downloads/android-studio-* -C ~/android-studio
  3. Move into the Android Studio directory: cd ~/android-studio/android-studio/bin
  4. Launch Android Studio: ./studio.sh
  5. Follow the setup wizard to install the necessary components.
  6. Open More ActionsSDK Manager and install the required SDK tools.
  7. If Flutter still cannot find the SDK, manually set its location: flutter config --android-sdk ~/Android/Sdk
  8. Accept Android licenses: flutter doctor --android-licenses

Step 5.5: Install the android sdk using the commandline tools.

Now if for some reason you hate the android studio IDE and prefer to work in VSCode Insiders, we can as well install the sdk using the command line tools which can be downloaded from Command line tools.

Extract the cmdline-tools folder to the home folder and add to path the binaries. For fish the command is

fish_add_path cmdline-tools/bin/

Then we can access the sdkmanager and install the sdk

sdkmanager "platform-tools" "platforms;android-36" "build-tools;36.0.0" --sdk_root="/home/(USER)/android"

in this command you can swap 36 with the target android sdk version.

sdkmanager "cmdline-tools;latest" --sdk_root="/home/(USER)/android"

Now to accept licences Where (USER) is your user name.

flutter doctor --android-licenses

After this flutter doctor should only complain about chrome which is not needed if you already have another browser. Restart any editors active and they should see the update.

Step 6: Run a Test App

Create a new Flutter project to test your installation:

flutter create my_app
cd my_app
flutter run

This should launch a sample app in an emulator or connected device.

Conclusion

You now have Flutter installed on Linux using Fish shell! Use flutter upgrade to keep your installation up to date. If flutter doctor still reports issues, follow its suggestions to resolve them.

Leave a Reply

Your email address will not be published. Required fields are marked *