mac 使用fvm管理 flutter 版本 Warning: `dart` on your path resolves to

問題

dart run build_runner build

使用如上命令,導(dǎo)致無法進(jìn)行rebuild,異常如下

Resolving dependencies in /Users/gaoxiaoxiong/project/flutter/myFirst_flutter... 
Because myFirst_flutter depends on flutter_test from sdk which doesn't exist (the Flutter SDK is not available), version solving failed.
Flutter users should use `flutter pub` instead of `dart pub`.

查看原因

flutter doctor


[!] Flutter (Channel stable, 3.22.1, on macOS 14.4.1 23E224 darwin-arm64, locale zh-Hans-CN)
    ! Warning: `dart` on your path resolves to /opt/homebrew/Cellar/dart/3.2.0/libexec/bin/dart, which is not inside your current Flutter SDK checkout at /Users/gaoxiaoxiong/fvm/versions/3.22.1. Consider adding
      /Users/gaoxiaoxiong/fvm/versions/3.22.1/bin to the front of your path.
[?] Android toolchain - develop for Android devices (Android SDK version 34.0.0)
[!] Xcode - develop for iOS and macOS
    ? Xcode installation is incomplete; a full installation is necessary for iOS and macOS development.
      Download at: https://developer.apple.com/xcode/
      Or install Xcode via the App Store.
      Once installed, run:
        sudo xcode-select --switch /Applications/Xcode.app/Contents/Developer
        sudo xcodebuild -runFirstLaunch
[?] Chrome - develop for the web
[?] Android Studio (version 2022.3)
[?] Connected device (3 available)
[?] Network resources

我環(huán)境變量里面配置的dart版本,跟我fvm全局配置的dart版本不同導(dǎo)致。因?yàn)槲乙郧笆褂胔omebrew 進(jìn)行安裝的

brew remove dart  //刪除已安裝的

fvm環(huán)境配置

export FVM_HOME="$HOME/fvm"
export PUB_HOSTED_URL=https://pub.flutter-io.cn
export FLUTTER_STORAGE_BASE_URL=https://storage.flutter-io.cn
export PATH="$HOME/fvm/default/bin:$PATH" //表示使用全局默認(rèn)配置的版本
?著作權(quán)歸作者所有,轉(zhuǎn)載或內(nèi)容合作請(qǐng)聯(lián)系作者
【社區(qū)內(nèi)容提示】社區(qū)部分內(nèi)容疑似由AI輔助生成,瀏覽時(shí)請(qǐng)結(jié)合常識(shí)與多方信息審慎甄別。
平臺(tái)聲明:文章內(nèi)容(如有圖片或視頻亦包括在內(nèi))由作者上傳并發(fā)布,文章內(nèi)容僅代表作者本人觀點(diǎn),簡(jiǎn)書系信息發(fā)布平臺(tái),僅提供信息存儲(chǔ)服務(wù)。

相關(guān)閱讀更多精彩內(nèi)容

友情鏈接更多精彩內(nèi)容