zsh: command not found: flutter

在用户目录下找到.zshrc 文件,用文本打开.zshrc文件。

如果没有配置flutter环境变量则添加,如果环境变量是export PATH="$PATH:[PATH_OF_FLUTTER_GIT_DIRECTORY]/bin"则修改成下面:

export PATH="$PATH:用户路径/flutter/bin"

例如: export PATH="$PATH:development/flutter/bin"

如果找不到,使用下面命令在终端执行,显示系统隐藏文件

defaults write com.apple.finder AppleShowAllFiles -boolean true ; killall Finder

如果隐藏,执行下面命令

defaults write com.apple.finder AppleShowAllFiles -boolean false ; killall Finder

重要提示:一定要重新打开一个终端或者,退出当前终端重新打开,执行flutter doctor

feng@bogon ~ % flutter doctor
Doctor summary (to see all details, run flutter doctor -v):
[✓] Flutter (Channel stable, 2.5.2, on Mac OS X 10.15.7 19H1519
darwin-x64, locale zh-Hans-CN)
[✓] Android toolchain - develop for Android devices (Android SDK
version 30.0.3)
[✓] Xcode - develop for iOS and macOS
[✓] Chrome - develop for the web
[✓] Android Studio (version 2020.3)
[✓] Connected device (2 available)

• No issues found!
feng@bogon ~ % flutter doctor
Doctor summary (to see all details, run flutter doctor -v):
[✓] Flutter (Channel stable, 2.5.2, on Mac OS X 10.15.7 19H1519
darwin-x64, locale zh-Hans-CN)
[✓] Android toolchain - develop for Android devices (Android SDK
version 30.0.3)
[✓] Xcode - develop for iOS and macOS
[✓] Chrome - develop for the web
[✓] Android Studio (version 2020.3)
[✓] Connected device (2 available)

• No issues found!

另外,下面两种方式也可以。

export PATH="/Users/feng/development/flutter/bin:$PATH"

export PATH="$PATH:/Users/feng/development/flutter/bin"

参考:https://stackoverflow.com/questions/58400500/zsh-command-not-found-flutter