Once you have installed Flutter in your development environment you will need to handle a couple of things like adding the SDK to the path permanently. Adding the Flutter SDK to the Linux path permanently permits you to run Flutter commands in any terminal. Now let’s get started on how you can add the Flutter SDK Linux path permanently
1) First step, determine the directory where you placed the downloaded or cloned flutter SDK. You can download it here if you don’t have it(choose a stable release).
Then move to your home folder and hit Ctrl+H to show all hidden files. Look for and open the file .bashrc.
Alternatively, you open a terminal and can run
gun@gun-Latitude-E6430:~$ sudo gedit ~/.bashrc
Note that If you are using a different shell, the file path and filename will be different on your machine.
2) Add the following line at the end of the ./bashrc file and save
export PATH="$PATH:[PATH_TO_FLUTTER_GIT_DIRECTORY]flutter/bin"
Where[PATH_TO_FLUTTER_GIT_DIRECTORY]
is the path where you placed the downloaded Flutter SDK for example
export PATH="$PATH:/home/kevine/flutter/bin"
3) Refresh your current window or open another tab to verify that the flutter/bin
directory is now in your PATH by running the command below:
gun@gun-Latitude-E6430:~$ echo $PATH
The results will look something like this below. Make sure you verify that the flutter path appears.
/home/gun/.nvm/versions/node/v12.20.0/bin:/usr/local/sbin:/usr/local/bin:/usr/sbin:/usr/bin:/sbin:/bin:/usr/games:/usr/local/games:/snap/bin:/usr/lib/dart/bin:/home/gun/Android/Sdk/emulator:/home/gun/Android/Sdk/tools:/home/gun/Android/Sdk/tools/bin:/home/gun/Android/Sdk/platform-tools:/home/gun/flutter/bin
If all goes well then you can start your flutter development and also start using flutter commands in any terminal.
Some flutter commands
flutter doctor
You can use the command above to see if there are any dependencies you need to install.
which flutter
This command verifies that the flutter
command is available.