android studio - Flutter command not found

ID : 20318

viewed : 9

Tags : android-studioflutterdartcommand-lineterminalandroid-studio

Top 5 Answer for android studio - Flutter command not found

vote vote

100

You need to correctly set up your Flutter path.

From macOS install - Update your path:

  1. Determine the directory where you placed the Flutter SDK. You will need this in Step 3.

  2. Open (or create) $HOME/.bash_profile. You can do that by using terminal text editor by going in terminal and typing nano ~/.bash_profile

    macOS v10.15 (Catalina) uses the Z shell by default, so edit $file HOME/.zshrc.

    If you are using a different shell, the file path and filename will be different on your machine.

  3. Add the following line and change [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 

    For example:

     export PATH=~/Documents/flutter/bin:$PATH 
  4. Press Ctrl + X and when it asks you to save the file, choose Yes

  5. Run source $HOME/.bash_profile to refresh the current window or restart the terminal

  6. Verify that the flutter/bin directory is now in your PATH by running:

     echo $PATH 

    Notice that [PATH_TO_FLUTTER_GIT_DIRECTORY] is where you installed Flutter SDK, not the location of your app

Instead of nano, you can use any text editor to edit file ~/.bash_profile.

For zsh:

  1. Open Terminal
  2. Run: nano ~/.zshrc
  3. Add: export PATH=[PATH_TO_FLUTTER_GIT_DIRECTORY]/flutter/bin:$PATH
  4. Run: source ~/.zshrc
  5. restart terminal
  6. Run: flutter doctor -v

For example : if flutter in your machine has been installed under [your_username]/Developer/flutter

export PATH=Developer/flutter/bin:$PATH 
vote vote

85

I tried out all the methods in previous answers, but all of them lasted only while the terminal was open. So I went ahead and directly added it to the path file permanently.

sudo nano /etc/paths 

Add this to the file:

/Users/yourUserName/Development/flutter/bin 

Save the file by pressing Ctrl + X, Y and then Enter. Close the terminal and reopen it again. Tada!

vote vote

70

If you are using zsh, you need to follow the steps below on Mac.

  • Download the latest Flutter version from the official site.
  • Unzip it and move to the $HOME location of your Mac.
  • Add to the path via the .zshrc file.
  • Run nano ~/.zshrc into an iTerm2 terminal.
  • Export PATH=$HOME/flutter/bin:$PATH
  • Save and close the ~/.zshrc file.
  • Restart iTerm2.
  • Now you will have the Flutter executable available.
vote vote

62

Do the following steps:

  1. Download the Flutter SDK

    Flutter SDK Archive

  2. Extract it where do you want (for example /home/development/flutter)

  3. Set your PATH. Edit your file with the command gedit ~/.profile. You need to add this line:

    export PATH=[location_where_you_extracted_flutter]/flutter/bin:$PATH 

    I showed you above where I've extracted mine, so my export will look like this:

    export PATH=/home/myUser/development/flutter/bin:$PATH 
  4. Save the file and close it.

  5. Run source ~/.profile to load the changes

  6. If you now run flutter doctor, it should work!

vote vote

54

If you are on macOS

First find the location of your Flutter SDK

Flutter SDK File: Write the below command on your terminal to download the Flutter SDK

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

For example: the SDK executable file name is flutter and it is in folder Downloads

Close and open your terminal again.

And enter the following commands in your terminal

cd Downloads # Go to Downloads  cd flutter   # Go to folder 'flutter'  pwd          # /Users/[USERNAME]/downloads/flutter/  whoami       # Your [USERNAME]  export PATH="/Users/[USERNAME]/downloads/flutter/bin":$PATH 

Top 3 video Explaining android studio - Flutter command not found

Related QUESTION?