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:
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:
At the end of the bashrc file, we will add this line:
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:
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:
Here is the output for the flutter doctor command:
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:
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:
If it gives any error, try this command:
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:
In Ubuntu or Mac OS, we can give the user permission by issuing this command:
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:
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.