最近更新到最新版本的Flutter后,我一直面临这个问题,不知道该怎么办。
作为我正在使用的一种解决方案:
flutter pub run build_runner build
代替:
dart run build_runner build
颤动版本:
Flutter 3.22.0 • 通道稳定 • https://github.com/flutter/flutter.git 框架 • 修订版 5dcb86f68f(13 天前) • 2024-05-09 07:39:20 -0500 发动机 • 修订版 f6344b75dc 工具 • Dart 3.4.0 • DevTools 2.34.3
这是我最近 Flutter 升级后遇到的错误:
❯ dart 运行 build_runner 构建 正在解决
中的依赖关系... 因为 dinebd_partner_mobile_app 依赖于 sdk 中的 flutter_test 不存在(Flutter SDK不可用),版本解析失败。/home/marlin/code/flutterApp/graphland-dev/dinebd_partner_mobile_app
Flutter 用户应该使用
flutter pub
而不是 dart pub
。
这是
pubspec.yaml
文件:
name: dinebd_partner_mobile_app
description: "A new Flutter project."
# The following line prevents the package from being accidentally published to
# pub.dev using `flutter pub publish`. This is preferred for private packages.
publish_to: "none" # Remove this line if you wish to publish to pub.dev
version: 1.0.0+1
environment:
sdk: ">=3.4.0 <4.0.0"
dependencies:
flutter:
sdk: flutter
# The following adds the Cupertino Icons font to your application.
# Use with the CupertinoIcons class for iOS style icons.
cupertino_icons: ^1.0.2
flutter_riverpod: ^2.4.10
go_router: ^14.1.1
flutter_secure_storage: ^9.0.0
dio: ^5.4.0
shared_preferences: ^2.2.2
geolocator: ^10.1.0
# network_info_plus: ^4.1.0
flutter_screenutil: ^5.9.0
flutter_svg: ^2.0.9
shimmer: ^3.0.0
flutter_hooks: ^0.20.4
graphql_flutter: ^5.1.2
cached_network_image: ^3.3.1
fluttertoast: ^8.2.4
url_launcher: ^6.2.3
form_validator: ^2.1.1
flutter_otp_text_field: ^1.1.1
dropdown_button2: ^2.3.9
dotted_border: ^2.1.0
equatable: ^2.0.5
intl: ^0.19.0
carousel_slider: ^4.2.1
image_picker: ^1.0.7
google_maps_flutter: ^2.5.3
flutter_rating_bar: ^4.0.1
json_annotation: ^4.9.0
freezed_annotation: ^2.4.1
# flutter_json_view: ^1.1.3
hooks_riverpod: ^2.4.10
dotted_line: ^3.2.2
uuid: ^4.3.3
crypto: ^3.0.3
flutter_html: ^3.0.0-beta.2
flutter_widget_from_html: ^0.14.11
logger: ^2.2.0
lottie: ^3.1.0
chat_bubbles: ^1.6.0
flutter_reaction_button: ^3.0.0+3
analyzer: ^6.4.1
dev_dependencies:
flutter_test:
sdk: flutter
flutter_lints: ^3.0.1
build_runner: ^2.4.8
freezed: ^2.4.7
json_serializable: ^6.7.1
graphql_codegen: ^0.13.11
flutter:
uses-material-design: true
我想跑步:
dart run build_runner build
仍然像以前一样工作,任何人都知道该怎么做。
我能够使用 FVM(Flutter 版本管理器)解决这个问题。
安装FVM后,运行
fvm use x.x.x # eg, 3.19.0
然后
fvm dart run build_runner build
希望您的问题能够得到解决。
总的来说,FVM 减少了与 Flutter 一起使用的麻烦。