Install Flutter on Mac

Tiempo de lectura: 2 minutos

Reading time: 2 minutes

Hello, today we are going to learn how to install Flutter on Mac.

First, open a terminal and create a new folder to install Flutter:

mkdir flutter_instalation

Next, download the Flutter repository using Git:

git clone https://github.com/flutter/flutter.git

Create the Flutter variable by running the ‘pwd’ command to see the current directory:

/Users/<user>/flutter_instalation

In the <user> part, your system username will appear.

Now, create the PATH as follows:

export PATH="$PATH:/Users/<user>/flutter_instalation/flutter/bin"

To store the configuration:

vim ~/.zshrc

Paste the above line:

export PATH="$PATH:/Users/<user>/flutter_instalation/flutter/bin"

Save by pressing :wq

Now, run ‘flutter doctor’:

sudo flutter doctor

Next, install Android Studio from this link: https://developer.android.com/studio/index.html

Once installed, open Android Studio and install the Android SDK (you will need to accept the licenses that appear on the left side). Click Next to install the SDK.

To verify that everything is installed correctly, run ‘flutter doctor’ again:

sudo flutter doctor

[✓] Android Studio (version 2022.2)

As an extra step, it is recommended to install Chrome to run web development with Flutter. https://www.google.com/intl/es_es/chrome/

If you see that some components like Android toolchain are not installed:

[!] Android toolchain – develop for Android devices (Android SDK version 34.0.0)
✗ cmdline-tools component is missing
Run path/to/sdkmanager --install "cmdline-tools;latest"
See https://developer.android.com/studio/command-line for more details.
✗ Android license status unknown.
Run flutter doctor --android-licenses to accept the SDK licenses.
See https://flutter.dev/docs/get-started/install/macos#android-setup for
more details.

Try to install it again:

  • Open the Android Studio SDK Manager and click on More actions:
  • Select the option to install Android SDK command line tools.
  • Click on Apply.

To resolve ✗ Android license status unknown., we need to run the following command:

flutter doctor --android-licenses

Accept the licenses when prompted.

[✓] Android toolchain – develop for Android devices

Now, we also need to install Xcode. Go to the App Store and search for Xcode, then install it.

Once installed, run the following commands in the terminal:

sudo xcode-select --install
sudo xcode-select --switch /Applications/Xcode.app/Contents/Developer
sudo xcodebuild -runFirstLaunch

If you encounter the message:

✗ CocoaPods installed but not working.

You need to reinstall CocoaPods by following these steps:

curl -L https://get.rvm.io  bash -s stable

After that, close the terminal and use the following commands:

rvm install ruby-2.7.2

rvm use ruby-2.7  

rvm --default use 2.7

Then, install CocoaPods:

sudo gem install cocoapods

It may take a while, then run ‘flutter doctor’ again to check.

Leave a Comment