Command Not Found

How to Solve Command Not Found in Flutter?

When the user installs and configures Flutter For the First time, when the user runs a command on a terminal, the user gets an error like Command Not Found. So in this article, we will go through How to Solve Command Not Found in Flutter.

How to Solve Command Not Found in Flutter?

You need to correctly set up your flutter path from here https://flutter.dev/docs/get-started/install/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 a terminal text editor by going in the terminal and typing nano ~/.bash_profile

macOS 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.

  • 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

Hence, directly add it to the path file permanently like below.

sudo nano /etc/paths

add this to the file

/Users/yourUserName/Development/flutter/bin
Users can try the below things
  • Download the Flutter SDK from 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

So our 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!

If you are using zsh, you need to follow the below steps in mac.

  • Download the latest flutter from the official site.
  • Unzip it and move to the $HOME location of your mac.
  • Add to the path via .zshrc file
  • run nano ~/.zshrc into iTerm2 terminal.
  • export PATH=$HOME/flutter/bin:$PATH
  • Save and close ~/.zshrc file.
  • re-start iTerm2
  • Now you will have Flutter available.

Do this to add Flutter permanently to your path in Ubuntu :

cd $HOME
gedit .bashrc
  • Append the line:
    export PATH="$PATH:[location_where_you_extracted_flutter]/flutter/bin"

    in the text file and save it.

  • source $HOME/.bashrc

    Open a new terminal and run the flutter doctor command

Flutter SDK can run on Windows as well as macOS

For Windows

  • First, download the latest SDK from the flutter download page.
  • Now to run flutter in the windows console you need to update your PATH environment variable.
  • From the Start search bar, type ‘env’ and select Edit environment variables for your account.
  • Under User, variables check if there is an entry called Path.

1. If the entry does exist, append the full path to flutter\bin using as a separator from existing values.

2. If the entry does not exist, create a new user variable named Path with the full path to flutter\bin as its value.

For Mac

  • First, download the latest SDK from the flutter download page
  • Extract the file in the desired location using the following commands :

1. cd ~/development
2.unzip ~/Downloads/flutter_macos_v1.5.4-hotfix.2-stable.zip

  • Add the flutter tool to your path:

1.export PATH=”$PATH:`pwd`/flutter/bin”

Run flutter doctor

For Linux: To remember flutter commands permanently:

  • open up terminal and cd to $HOME. for eg: username@linux:~$
  • open the hidden file .bashrc with your desired editor. It resides in $HOME.eg. sudo gedit .bashrc
  • add the following line export PATH=/home/username/flutter/bin:$PATH somewhere as a newline in .bashrc file preferably as the last line edit & save the file.
  • Run source /home/yourname/.bashrc in terminal to process your recent changes.
  •  Finally, run echo $PATH to see flutter dir is in your system path along with other such paths for eg: /home/username/flutter/bin

Conclusion:

So in this article, we have learned about how to Solve Command Not Found in Flutter.

Thanks for Reading!!! Keep Fluttering.

Do let us know if you need any assistance with Flutter Development?

Flutter Agency is one of the most popular online portals dedicated to Flutter Technology and daily thousands of unique visitors come to this portal to enhance their knowledge of Flutter.

At Flutter Agency, we understand the challenges developers face, such as encountering the “command not found” error in Flutter. Our expertise as a mobile apps development agency allows us to provide comprehensive support to help you resolve these issues efficiently. Whether you’re setting up your development environment or troubleshooting errors, our team is here to assist you every step of the way. Trust us to help streamline your Flutter development process and ensure your projects run smoothly.

Frequently Asked Questions (FAQs)

1. Which coding is used in Flutter app development?

Flutter code compiles to the ARM or Intel machine code and JavaScript for fast performance on any device.

2. What is the main objective of Flutter?

Flutter is Google’s portable UI toolkit for developing beautiful, native compiled mobile, web, and desktop apps from a single codebase. Flutter will work with free and open-source code being used by Flutter developers and organizations worldwide.

3. How do you fix Flutter if it is not identified as an internal or external command?

Go to my computer programs>advanced system setting>environment variables. In this manner, you can solve Flutter, which is not recognized as an external or internal command issue in the windows operating system

Nirali Patel

Written by Nirali Patel

Nirali Patel is a dedicated Flutter developer with over two years of experience, specializing in creating seamless mobile applications using Dart. With a passion for crafting user-centric solutions, Nirali combines technical proficiency with innovative thinking to push the boundaries of mobile app development.

Leave a comment

Your email address will not be published. Required fields are marked *


Discuss Your Project

Connect with Flutter Agency's proficient skilled team for your app development projects across different technologies. We'd love to hear from you! Fill out the form below to discuss your project.

Have Project For Us

Get in Touch

"*" indicates required fields

ready to get started?

Fill out the form below and we will be in touch soon!

"*" indicates required fields