问题
dart run build_runner build
使用如上命令,导致无法进行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
我环境变量里面配置的dart版本,跟我fvm全局配置的dart版本不同导致。因为我以前使用homebrew 进行安装的
brew remove dart //删除已安装的
fvm环境配置
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" //表示使用全局默认配置的版本