Search⌘ K
AI Features

Flutter Installation for macOS and Linux

Understand the complete process of installing Flutter on macOS and Linux systems. This lesson guides you through downloading Flutter, configuring system paths, setting up Android Studio, launching virtual devices, and resolving common permission issues to prepare your environment for Flutter app development.

We'll cover the following...

For local Flutter setup, our first task is to install the Flutter framework. Next, to download and install Flutter, we need to go to the Flutter installation page.

Downloading Flutter for macOS and Linux is the same.

Flutter installation guide

Clicking on the download button will download the flutter_linux_2.2.3-stable.tar.xz file in your Downloads folder.

Next, we will issue the following command to extract Flutter on our terminal:

Shell
tar xf flutter_linux_2.2.3-stable.tar.xz

We can now copy this extracted flutter directory to a suitable place to build our first mobile application. In the Documents directory, we have created another directory named development. We will keep the extracted flutter directory there.

Just like Windows 10, we will now set the global path for Flutter so that we can use the flutter command anywhere in our machine in the future. The commands are identical for any macOS or Linux operating system.

We will use Vim or nano text editor, which works on the terminal. The nano text editor will open up the bashrc file if we type the following command:

Shell
nano ~/.bashrc

At the end of the bashrc file, we will add this line:

Shell
export PATH=$PATH:/home/ss/Documents/development/flutter/bin:$PATH

We have to mention the full path as given above. We have kept our extracted flutter/bin folder in the /home/ss/Documents/development directory.

Our next step is to download Android Studio. Download the zipped folder and extract it anywhere in the machine. We have kept it in our /home/ directory. Next, issue these commands:

Dart
cd android-studio/bin/
./studio.sh

It will open up Android Studio for us.

Once Android Studio opens up, we can go to the “open folde” option and choose the flutter project we have created already. How we have made it, we will discuss this later.

Before that, we need to see Android Studio and our newly created virtual device.

Before we open Android Studio, we will open our terminal and type in the following commands to reach the newly installed flutter directory:

Shell
cd Documents/development/flutter/
flutter doctor

Here is the output for the flutter doctor command:

Shell
ss@ss-desktop:~$ cd Documents/development/flutter/
ss@ss-desktop:~/Documents/development/flutter$ flutter doctor
Doctor summary (to see all details, run flutter doctor -v):
[✓] Flutter (Channel stable, v1.17.2, on Linux, locale en_IN)
[✓] Android toolchain - develop for Android devices (Android SDK version 29.0.3)
[✓] Android Studio (version 3.5)
[✓] Android Studio (version 4.0)
[✓] IntelliJ IDEA Community Edition (version 2019.3)
[✓] VS Code (version 1.43.2)
[!] Connected device
! No devices available
! Doctor found issues in 1 category.
ss@ss-desktop:~/Documents/development/flutter$

As we can see in the above output, flutter doctor has found only one issue. It has not found any connected device. Apart from that, we can see that we have successfully installed Android Studio, IntelliJ IDEA Community Edition, and Visual Studio Code.

We can use the virtual device from the Android Studio, but we will use Visual Studio Code or IntelliJ IDEA Community Edition for writing our code. They will automatically synchronize with the connected device. However, before that, we need to create our first Flutter project with the help of the flutter command as follows:

Shell
flutter create my_first_flutter_app

Remember, when we want to create a new Flutter project, we should always make it as shown above. The naming convention is essential here. We can only use the underscore between the words. No hyphens or spaces are allowed.

Now we will go back to the Android Studio. We will pick up the “open folder” option and open the newly created Flutter project. We have named it: my_first_flutter_app.

Then select any one of them and click the green “Play” button on the far right-hand side of any virtual device. It will automatically open up the connected device.

Now everything is ready. We can build a mobile application from scratch using Flutter and Dart.

Before we conclude this section, we should know a few good tips. Usually, the beginners encounter a few errors when they try to run the command:

Shell
flutter doctor

If it gives any error, try this command:

Shell
flutter doctor --android-licenses

It will ask you to accept the license. Accept it, and it will not give any error anymore. But, unfortunately, new Flutter developers are often stuck with another issue. They cannot launch the virtual mobile device while working with Android Studio.

Every code we write should reflect the virtual device, which the AVD manager can do. But sometimes, an ugly error pops up and gives us the following error message:

Shell
/dev/kvm permission denied

In Ubuntu or Mac OS, we can give the user permission by issuing this command:

Shell
sudo chmod 777 -R /dev/kvm

But it has a drawback. If someone else uses our machine, then the other user also gets the permission.

The best remedy is to give the necessary permissions to yourself only by the following commands:

Shell
sudo apt install qemu-kvm
sudo adduser your-username kvm
sudo chown your-username /dev/kvm

It will solve the issue forever. Now we can launch any virtual device we want. We can start the device with our Android Studio and work with any other IDE like IntelliJ or Visual Studio Code.