Flutter commands not working

bash: flutter: command not found


Hi everyone! Apparently none of the flutter commands are working on the terminal of android studio which I believe I am trying to run it at the root of my project.
Thank you in advance

You need to correctly set up your flutter path.

from here
https://flutter.io/setup-macos/#update-your-path


Determine the directory where you placed the Flutter SDK. You will need this in Step 3.
Open (or create) $HOME/.bash_profile. You can do that by using terminal text editor by going in terminal and typing nano ~/.bash_profile
Add the following line and change [PATH_TO_FLUTTER_GIT_DIRECTORY] to be the path where you cloned Flutter’s git repo:


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

for example:

export PATH=~/Documents/flutter/bin:$PATH


press CTRL X and when it asked you to save the file, choose yes
Run source $HOME/.bash_profile to refresh the current window or restart the terminal
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 ~/.bash_profile

Do the following steps:


Download the Flutter SDK
Flutter SDK Archive
Extract it where do you want (for example /home/development/flutter)
Set your PATH, edit your file with this 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



Save the file and close it.
Run source ~/.profile to load the changes
If you run now flutter doctor should work!


You can easily create a symbolic link as below,

sudo ln -s /opt/flutter/bin/flutter /usr/bin/flutter


I had moved flutter into /opt/ folder after downloading, so replace with the path you have flutter directory.

flutter command should work even after rebooting your machine.

Comments

Popular posts from this blog

flutter websocket connection issue

Webpack 5 and Storybook 6 integration throws an error in DefinePlugin.js

Meaning of `{}` for return expression