問題
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)配置的版本