How To Install Flutter on Rocky Linux 9
Flutter, developed by Google in 2015 and released in 2018, has rapidly become a favorite toolkit for developers aiming to craft natively compiled applications for mobile, web, and desktop from a single codebase. Its popularity stems from its ability to provide a fast and efficient development experience, a rich set of pre-designed widgets, and excellent performance across different platforms. This comprehensive guide will walk you through the process of installing Flutter on Rocky Linux 9, ensuring you have a smooth setup and are ready to start building amazing cross-platform applications. Rocky Linux 9, known for its stability and reliability, provides an excellent environment for Flutter development. The increasing adoption of Flutter makes mastering its installation process invaluable for modern developers.
Prerequisites
Before diving into the installation process, it’s essential to ensure your system meets the necessary requirements. Proper preparation will help avoid potential issues and ensure a seamless installation. Here’s a breakdown of what you need:
- Hardware Requirements:
- CPU: A minimum of 4 CPU cores is recommended, but 8 cores are preferable for smoother performance, especially when running emulators or larger projects.
- Memory: 8GB of RAM is the minimum, though 16GB is highly recommended. More memory allows for better multitasking and reduces the likelihood of slowdowns.
- Display Resolution: A resolution of 1280 x 720 is the minimum, but a higher resolution will provide a better development experience.
- Disk Space: At least 11GB is required for Flutter, Dart SDK, and related dependencies. For a comfortable development environment, 60GB is recommended to accommodate Android Studio, emulators, and other tools.
- User Privileges: You will need a normal user account with sudo privileges or direct access to the root account to perform the installation.
- Software Requirements:
- Operating System: Rocky Linux 9 is the target platform for this guide.
- Development Tools: The following tools are required:
curl
,git
,unzip
,xz-utils
,zip
, andlibglu1-mesa
. These tools are commonly used for downloading, managing, and extracting files, as well as providing necessary libraries for Flutter.
Updating Your System
Keeping your system up-to-date is crucial before installing any new software. An updated system ensures that you have the latest security patches and package versions, which can prevent compatibility issues during the installation process. Here’s how to update your Rocky Linux 9 system:
sudo dnf clean all
sudo dnf update
The sudo dnf clean all
command clears the DNF (Dandified YUM) cache, removing any old or obsolete package data. This ensures that the next update fetches the latest package information from the repositories. Following this, the sudo dnf update
command updates all installed packages to their latest available versions. This process ensures that your system is running the most current software, reducing potential conflicts and improving overall system stability.
Installing Dependencies
Flutter relies on a number of dependencies to function correctly. These dependencies provide essential libraries and tools that Flutter uses during development. Installing these dependencies ensures that Flutter can operate seamlessly on your Rocky Linux 9 system. Here’s how to install the required dependencies using the DNF package manager:
sudo dnf install bash curl file git unzip which xz zip mesa-libGLU clang cmake ninja-build pkg-config
Let’s break down each dependency and its role:
bash
: A command-line interpreter that executes commands entered by the user. It is essential for running shell scripts and various system operations.curl
: A command-line tool used for transferring data with URLs. It is used to download files from the internet, which is necessary for fetching the Flutter SDK.file
: A utility for determining the type of a file. It is used to identify file formats and ensure they are handled correctly.git
: A distributed version control system for tracking changes in source code during software development. Flutter uses Git for managing its codebase and for updating the framework.unzip
: A tool for extracting files from ZIP archives. The Flutter SDK is distributed as a ZIP file, so this tool is necessary for unpacking it.which
: A command that locates the executable file associated with a given command. It is useful for verifying that commands are available in the system’s PATH.xz
andzip
: Utilities for handling compressed files in XZ and ZIP formats, respectively. These tools are used for compressing and decompressing files, which is essential for managing the Flutter SDK.mesa-libGLU
: An open-source implementation of the OpenGL Utility Library (GLU). It provides functions for performing complex rendering tasks, which are used by Flutter for its graphical interface.clang
: A C language family frontend for LLVM. It is a compiler used to compile C, C++, and Objective-C code.cmake
: An open-source, cross-platform build system generator. It is used to manage the build process for Flutter projects.ninja-build
: A small build system with a focus on speed. It is used to build Flutter projects quickly and efficiently.pkg-config
: A helper tool used to compile software packages. It is used to locate and configure the necessary libraries and dependencies for Flutter.
Installing Flutter SDK
With the dependencies in place, the next step is to download and install the Flutter SDK. The SDK contains the necessary tools and libraries for developing Flutter applications. Here’s a step-by-step guide to installing the Flutter SDK on Rocky Linux 9:
- Download the Flutter SDK:
- Visit the official Flutter website to find the latest stable release of the Flutter SDK for Linux.
- Use the
wget
command to download the Flutter SDK. Ensure you replace the link with the latest stable release link from the Flutter website.
wget https://storage.googleapis.com/flutter_infra_release/releases/stable/linux/flutter_linux_3.16.9-stable.tar.xz
- Create a Dedicated Directory:
- Create a dedicated folder for Flutter to keep things organized. This helps maintain a clean directory structure and makes it easier to manage your Flutter installation.
mkdir ~/development cd ~/development
- Extract the Flutter SDK:
- Extract the downloaded Flutter SDK to the created directory. Adjust the paths according to your actual download location and desired installation directory.
tar -xf ~/Downloads/flutter_linux_3.16.9-stable.tar.xz -C ~/development/
After these steps, the Flutter SDK will be installed in the ~/development/flutter
directory.
Setting Up the Environment Variables
To use Flutter commands globally, you need to add Flutter to your system’s PATH. This allows you to run Flutter commands from any terminal window without specifying the full path to the Flutter executable. Here’s how to set up the environment variables:
- Open the
.bashrc
or.zshrc
File:- Open the
.bashrc
file if you are using Bash, or the.zshrc
file if you are using Zsh. You can use a text editor like Nano or Vim to edit the file.
nano ~/.bashrc
or
nano ~/.zshrc
- Open the
- Add Flutter to the PATH:
- Add the following line to the end of the file. Adjust the path if you installed Flutter in a different directory.
export PATH="$PATH:~/development/flutter/bin"
- Save the File and Close the Text Editor:
- Press
Ctrl+X
, thenY
, and thenEnter
to save the changes and exit Nano.
- Press
- Apply the Changes to the Current Session:
- Apply the changes to the current session by running the following command. This reloads the
.bashrc
or.zshrc
file, making the new environment variables available.
source ~/.bashrc
or
source ~/.zshrc
- Apply the changes to the current session by running the following command. This reloads the
With these steps, Flutter is now added to your system PATH, allowing you to run Flutter commands from any terminal window.
Verifying the Installation
After installing Flutter and setting up the environment variables, it’s important to verify that Flutter is installed correctly. The flutter doctor
command checks your environment and displays a report of the status of your Flutter installation. Here’s how to verify the installation:
flutter doctor
The flutter doctor
command examines your environment and checks for any missing dependencies or configuration issues. The output of the command will indicate whether Flutter is installed correctly and whether any additional steps are required. Here’s how to interpret the output:
- If Flutter is installed correctly: The output will show a list of checks, and all of them should be marked with a green checkmark.
- If there are missing dependencies or issues: The output will show a list of checks, and any missing dependencies or issues will be marked with a red cross. The output will also provide instructions on how to resolve these issues.
Common issues that flutter doctor
might identify include:
- Missing Android SDK: If the Android SDK is not installed,
flutter doctor
will prompt you to install it. You can install the Android SDK using Android Studio or by downloading it from the Android developer website. - Missing Licenses: If you have not accepted the Android SDK licenses,
flutter doctor
will prompt you to accept them. You can accept the licenses by running theflutter doctor --android-licenses
command. - Other Issues:
flutter doctor
may also identify other issues, such as missing dependencies or outdated tools. Follow the instructions provided byflutter doctor
to resolve these issues.
By running flutter doctor
and resolving any identified issues, you can ensure that your Flutter installation is working correctly and that you are ready to start developing Flutter applications.
Configuring Android Studio
Android Studio is a popular Integrated Development Environment (IDE) for developing Android applications. It provides a rich set of tools and features that can help you develop Flutter applications more efficiently. Configuring Android Studio for Flutter development involves installing the Flutter and Dart plugins, configuring the Android SDK, and accepting the Android licenses. Here’s how to configure Android Studio for Flutter development:
- Download and Install Android Studio:
- Download Android Studio from the official Android developer website.
- Follow the installation instructions to install Android Studio on your Rocky Linux 9 system.
- Install the Flutter and Dart Plugins:
- Open Android Studio.
- Go to
File > Settings > Plugins
. - Search for “Flutter” and install the Flutter plugin. It will prompt you to install the Dart plugin as well.
- Restart Android Studio after installing the plugins.
- Configure the Android SDK:
- Open Android Studio.
- Go to
File > Settings > Appearance & Behavior > System Settings > Android SDK
. - Install the latest Android SDK Platform.
- Set the
ANDROID_HOME
environment variable.- Add the following lines to your
.bashrc
or.zshrc
file, replacing/path/to/android/sdk
with the actual path to your Android SDK:
export ANDROID_HOME=/path/to/android/sdk export PATH="$PATH:$ANDROID_HOME/cmdline-tools/latest/bin:$ANDROID_HOME/platform-tools:$ANDROID_HOME/tools"
- Add the following lines to your
- Apply the changes to the current session by running
source ~/.bashrc
orsource ~/.zshrc
.
- Accept Android Licenses:
- Run the following command to accept the Android licenses:
flutter doctor --android-licenses
- Follow the prompts to accept the licenses.
After these steps, Android Studio will be configured for Flutter development, and you will be able to create and run Flutter applications using Android Studio.
Creating Your First Flutter App
Now that Flutter is installed and configured, it’s time to create your first Flutter application. This will help you verify that everything is working correctly and give you a basic understanding of the structure of a Flutter project. Here’s how to create your first Flutter app:
- Create a New Flutter Project:
- Use the
flutter create
command to create a new Flutter project. Replacemy_first_app
with the desired name for your project.
flutter create my_first_app cd my_first_app
- Use the
- Run the App:
- Run the app on an Android emulator or connected device. Make sure you have an Android emulator set up in Android Studio or a physical Android device connected to your computer.
flutter run
The flutter run
command will build and run the Flutter application on the selected device or emulator. You should see the default Flutter demo app running on your device.
The basic structure of a Flutter project includes the following directories:
android/
andios/
: These directories contain platform-specific code for Android and iOS, respectively. You typically don’t need to modify these directories unless you need to add custom platform-specific functionality.lib/
: This directory contains the Dart code for your application. This is where you will spend most of your time writing code for your Flutter app.lib/main.dart
: This is the main entry point for your application. It contains themain()
function, which is the first function that is executed when your app is launched.
To modify the app’s title or theme, you can edit the lib/main.dart
file. For example, you can change the app’s title by modifying the title
property of the MaterialApp
widget.
Flutter also supports hot reload, which allows you to quickly see the changes you make to your code without restarting the app. To use hot reload, simply save the changes to your code, and Flutter will automatically update the app running on your device or emulator.
Troubleshooting Common Issues
While installing Flutter, you might encounter some common issues. Here are some troubleshooting tips to help you resolve them:
- “Flutter command not found”:
- Ensure that Flutter’s
bin
directory is in your PATH. Double-check the steps in the “Setting Up the Environment Variables” section and make sure you have correctly added Flutter to your PATH.
- Ensure that Flutter’s
- “Android toolchain not found”:
- Make sure Android Studio is installed and configured correctly. Verify that you have installed the Android SDK and set the
ANDROID_HOME
environment variable.
- Make sure Android Studio is installed and configured correctly. Verify that you have installed the Android SDK and set the
- “Unable to accept Android licenses”:
- Run
flutter doctor --android-licenses
and accept all licenses. Follow the prompts to accept the licenses.
- Run
- “Emulator not starting”:
- Ensure that virtualization is enabled in your BIOS. Virtualization is required to run Android emulators.
- “App not running on device”:
- Enable developer mode and USB debugging on your Android device. You can enable developer mode by going to
Settings > About phone
and tapping the “Build number” seven times. Then, enable USB debugging in the developer options.
- Enable developer mode and USB debugging on your Android device. You can enable developer mode by going to
By following these troubleshooting tips, you can resolve common issues and ensure a smooth Flutter installation experience.
Optimizing Flutter Development on Rocky Linux 9
To enhance your Flutter development experience on Rocky Linux 9, consider the following optimizations:
- Use an IDE with Flutter Plugins:
- Using an IDE such as VS Code or Android Studio with Flutter plugins can significantly improve your development workflow. These plugins provide features such as code completion, debugging, and hot reload.
- Make Use of Flutter’s Hot Reload Feature:
- Flutter’s hot reload feature allows you to quickly see the changes you make to your code without restarting the app. This can save you a lot of time during development.
- Use Git for Version Control:
- Use Git for version control to manage changes to your codebase effectively. This allows you to track changes, collaborate with others, and revert to previous versions if necessary.
By implementing these optimizations, you can create a more efficient and productive Flutter development environment on Rocky Linux 9.
Congratulations! You have successfully installed Flutter. Thanks for using this tutorial for installing the Flutter open-source UI software development kit on your Rocky Linux 9 system. For additional or useful information, we recommend you check the official Flutter website.