Updating the PATH variable for Flutter on Mac
( 379 Articles)
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:
Change [PATH_TO_YOUR_FLUTTER_DIRECTORY] with your own path (the place flutter was downloaded on your computer). You can show your flutter directory absolute path 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:
You should see something like this:
That’s all, buddy. Further reading:
- Using Chip widget in Flutter: Tutorial & Examples
- Flutter: Changing App Display Name for Android & iOS
- Flutter: Creating Custom Back Buttons
- Flutter: SliverGrid example
- Flutter: Columns with Percentage Widths