Mac build flutter environment

Recently, I changed to a new computer. Since the default terminal loads zsh after mac11, it is a little different from the old system before mac11. Here is a record of the latest flutter environment process.

1. Download flutter from the official website

Flutter | Flutter SDK releases

After decompression, put it in a fixed directory, which will be used later and cannot be deleted

2. Open the terminal and edit the .bash_profile file

 sudo vi ~/.bash_profile

Add the following configuration

//1 and 2 are mirror images that domestic users need to set

export PUB_HOSTED_URL=https://pub.flutter-io.cn
export FLUTTER_STORAGE_BASE_URL=https://storage.flutter-io.cn
export PATH=`pwd`Here is replaced with the downloaded flutter file path/bin:$PATH
export PATH= Replace `pwd` with the downloaded flutter file path /bin/cache/dart-sdk/bin:$PATH

After editing, press the ESC key, enter: wq, you can save and exit

Finally, be sure to refresh the .bash_profile file

 source ~/.bash_profile

3. Restart the terminal and run

flutter doctor

Under normal circumstances, it will download and complete the configuration installation, but the new system loads the zsh configuration by default, prompting -bash: flutter: command not found or zsh: command not found: flutter

Solution:

sudo vi ~/.zprofile

Add the following configuration

export PATH="$PATH: Change here to the downloaded flutter file path/bin"

After editing, press the ESC key, enter: wq, you can save and exit

Finally, be sure to refresh the .zshrc file

source ~/.zprofile

Restart the terminal, run flutter doctor, prompt

Error: The Flutter directory is not a clone of the GitHub project.

       The flutter tool requires Git in order to operate properly;

       to install Flutter, see the instructions at:

       https://flutter.dev/get-started

In the downloaded flutter file directory, just execute git init

Re-run flutter doctor

Wait for the download to complete

The flutter environment configuration is complete

Guess you like

Origin blog.csdn.net/u012378566/article/details/120231092