Home » Application Stack / User Interface » Flutter » How to Install Flutter on Ubuntu Linux : Step-by-Step Guide

How to Install Flutter on Ubuntu Linux : Step-by-Step Guide

Suggested SEO-Optimized Title:

“Step-by-Step Guide: How to Install Flutter on Ubuntu Linux”


Blog Post: How to Install Flutter on Ubuntu Linux

Flutter, developed by Google, is a popular open-source framework that allows developers to build beautiful, natively compiled applications for mobile, web, and desktop from a single codebase. Installing Flutter on Ubuntu Linux is straightforward and can be done by following a few simple steps.

In this guide, we’ll walk you through the entire process of installing Flutter on Ubuntu Linux, from setting up the required dependencies to running your first Flutter app. By the end, you’ll have everything you need to start developing apps using Flutter on your Ubuntu machine.


Prerequisites

Before we dive into the installation process, make sure you have the following:

  • Ubuntu 18.04 or later installed on your system.
  • Basic knowledge of the Linux terminal (commands like cd, sudo, etc.).

Additionally, ensure your system meets the following minimum requirements:

  • Git: Flutter uses Git for version control, so you’ll need it installed.
  • Disk space: Ensure you have at least 2 GB of free space available.

Step 1: Install Required Dependencies

Before installing Flutter, you need to ensure that the necessary dependencies are installed on your system.

Open a terminal and run the following command to install Git, curl, and other required tools:

sudo apt update
sudo apt install git curl unzip xz-utils libglu1-mesa
  • Git: Used to download Flutter’s source code.
  • curl: Used for downloading files from the web.
  • unzip & xz-utils: Tools for extracting compressed files.
  • libglu1-mesa: Required for running Flutter applications on Linux.

Step 2: Download Flutter SDK

Now that the dependencies are installed, it’s time to download the Flutter SDK.

  1. Open a terminal.
  2. Run the following command to download the latest stable version of Flutter SDK:
git clone https://github.com/flutter/flutter.git -b stable

This command clones the Flutter repository and downloads the stable branch of the SDK.

  1. Once the download is complete, add Flutter to your system’s path by modifying the .bashrc file:
export PATH="$PATH:`pwd`/flutter/bin"
  1. Apply the changes:
source ~/.bashrc

This ensures that you can run Flutter commands from any terminal window.


Step 3: Verify Flutter Installation

To confirm that Flutter is installed correctly, use the following command:

flutter doctor

The flutter doctor command checks your environment and displays a report of any missing dependencies. For a typical Ubuntu installation, you might see a message indicating that Android Studio or Xcode (for macOS) is not installed, but these are not required if you’re only developing for the web or desktop.

If there are any other issues (e.g., missing tools), the report will guide you on how to resolve them.


Step 4: Install Android Studio (Optional for Mobile Development)

If you plan to develop mobile applications with Flutter, you’ll need to install Android Studio to access the Android SDK and emulator. Here’s how to install Android Studio on Ubuntu:

  1. Download Android Studio:
sudo snap install android-studio --classic
  1. Once installed, open Android Studio and go to SDK Manager to install the Android SDK.
  2. Run the flutter doctor command again to ensure that Android Studio is properly configured.
flutter doctor

If everything is set up correctly, you’ll see a message indicating that your environment is ready for mobile development.


Step 5: Set Up a Device (Emulator or Physical Device)

Flutter requires either a physical device or an emulator to run your apps. You can use an Android phone or set up an Android Emulator in Android Studio.

To set up an Android Emulator:

  1. Open Android Studio and go to AVD Manager (Android Virtual Device Manager).
  2. Create a new virtual device and configure it according to your preferences.
  3. Start the emulator.

Alternatively, if you’re using a physical Android device, enable Developer Mode and USB Debugging on your phone, then connect it to your Ubuntu system via USB.


Step 6: Create Your First Flutter App

Now that Flutter is installed and your environment is ready, you can create your first Flutter app.

  1. In the terminal, run the following command to create a new Flutter project:
flutter create my_first_app

This will create a new Flutter app in a directory called my_first_app.

  1. Navigate to the app’s directory:
cd my_first_app
  1. Run the app using the following command:
flutter run

If everything is set up correctly, Flutter will build and run the app on your connected device or emulator.


Troubleshooting Tips

  • Permissions issue: If you encounter permission-related errors, try running the flutter commands with sudo.
  • Android Studio not detected: Ensure that the Android SDK is installed and properly configured in Android Studio. Re-run flutter doctor to check for any issues.

Installing Flutter on Ubuntu Linux is a simple process if you follow the steps outlined in this guide. With the Flutter SDK installed, you can now start developing beautiful apps for mobile, web, and desktop platforms right from your Linux environment.

Whether you’re building apps for Android or just experimenting with Flutter on the web, this setup will help you get started. Now, you can take advantage of Flutter’s powerful features and Google’s rich ecosystem to create amazing apps with ease.

Leave a Comment