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:

sudo dnf install gtk3-devel  # Fedora
sudo apt install libgtk-3-dev  # Debian/Ubuntu
sudo pacman -S gtk3  # Arch Linux

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