Problem Description
You have installed Flutter on your system, but whenever you try to run any Flutter command (like `flutter doctor` or `flutter create`), you get an error message saying that the `flutter` command is not found.
Solution: Adding Flutter Path Correctly
Adding Flutter path correctly will solve this problem. Here’s how you can do it:
### Step 1: Determine the Directory Where You Placed the Flutter SDK
Determine the directory where you placed the Flutter SDK. You will need this in Step 3.
# Example: # PATH_TO_FLUTTER_GIT_DIRECTORY = /Users/your_username/Development/flutter
Step 2: Update Your Path (macOS)
Update your path:
### macOS v10.14 and earlier
nano ~/.bash_profile
to open or create the file.- Add the following line, changing
[PATH_TO_FLUTTER_GIT_DIRECTORY]
to be the path where you cloned Flutter’s Git repository is: Ctrl + X
, then chooseYes
when it asks you to save the file.source $HOME/.bash_profile
to refresh the current window or restart the terminal.
export PATH=[PATH_TO_FLUTTER_GIT_DIRECTORY]/flutter/bin:$PATH
Step 3: Verify That the Flutter/bin Directory is Now in Your PATH (macOS)
Verify that the flutter/bin
directory is now in your PATH by running:
echo $PATH
Alternative Instructions for zsh Users (macOS)
nano ~/.zshrc
- Add:
export PATH=[PATH_TO_FLUTTER_GIT_DIRECTORY]/flutter/bin:$PATH
source ~/.zshrc
- Restart the terminal.
flutter doctor -v
Alternative Instructions for macOS v10.15 (Catalina)
macOS v10.15 (Catalina) uses the Z shell by default, so edit $HOME/.zshrc
. If you are using a different shell, the file path and filename will be different on your machine.
Step 1: Open Terminal
nano ~/.zshrc
Step 2: Add Export Command
Add the following line:
export PATH=[PATH_TO_FLUTTER_GIT_DIRECTORY]/flutter/bin:$PATH
Step 3: Run source command to refresh zsh configuration
source ~/.zshrc
Step 4: Restart the Terminal
Restart the terminal.
Alternative Instructions for Older macOS and Linux Systems
On older systems (pre-macOS v10.15), follow these steps:
### Step 1: Open Your Text Editor
nano ~/.bash_profile
Step 2: Add Export Command
Add the following line, changing [PATH_TO_FLUTTER_GIT_DIRECTORY]
to be the path where you cloned Flutter’s Git repository is:
export PATH=[PATH_TO_FLUTTER_GIT_DIRECTORY]/flutter/bin:$PATH
Step 3: Save and Close the File
Ctrl + X
, then choose Yes
when it asks you to save the file.
Alternative Method for Adding Flutter Path Permanently (macOS)
This method permanently adds Flutter path without requiring restart or running `source` command after each terminal session.
### Step 1: Open the Terminal
nano /etc/paths
Step 2: Add Export Command Permanently
Add this to the file:
/Users/yourUserName/Development/flutter/bin
Step 3: Save and Close the File
Ctrl + X
, then choose Yes
when it asks you to save the file.
Conclusion
By following these steps, you should be able to add Flutter path correctly on your macOS system. Remember that you might need to restart your terminal or run `source` command after each step if using older macOS or Linux systems.
Common Mistakes and Troubleshooting Tips
Here are some common mistakes people make when trying to add Flutter path:
### Common Mistake 1: Using the wrong shell
- Verify which shell you’re using (bash or zsh).
Troubleshooting Tip 1:
If you’ve added Flutter path correctly but still get errors, try restarting your terminal.
Common Mistake 2: Using the wrong directory
- Verify that you’re adding the correct path for your Flutter SDK installation.
Troubleshooting Tip 2:
Try running echo $PATH
to verify if Flutter path is correctly added.