After downloading Flutter, you need to update your path in order to run flutter commands via the terminal. In macOS 10.15 or beyond (Catalina, Big Sur, Monterey), you need to edit the .zshrc file instead of the .bashrc or .bash_profile file.
In the process, you may face a big problem: you cannot find the .bashrc file on your Mac. The steps below will help you.
1. First, navigate to Go > Home from your Desktop screen:
Now, you are at the Home directory, but the .zshrc file is hidden and you still cannot see it:
2. Simply press “command” + “shift” + “>” to show all the hidden files. After that, open the .zshrc file with your favorite text editor.
3. Add this line to the .zshrc file:
export PATH="$PATH:[PATH_TO_YOUR_FLUTTER_DIRECTORY]/flutter/bin"
Change [PATH_TO_YOUR_FLUTTER_DIRECTORY] with your own path (the place flutter was downloaded on your computer). You can show the absolute path of your flutter directory by right click on it and selecting “Get info”.
In my case, the .zshrc file looks like this:
4. Test your work by opening your Mac terminal and executing the command below:
flutter doctor
You should see something like this:
That’s all, buddy. Further reading:
- Using Chip widget in Flutter: Tutorial & Examples
- 4 Ways to Create Full-Width Buttons in Flutter
- Flutter: Changing App Display Name for Android & iOS
- Flutter: Creating Custom Back Buttons
- Flutter: SliverGrid example
- Flutter: Columns with Percentage Widths
You can also take a tour around our Flutter topic page and Dart topic page to see the latest tutorials and examples.