提问人:pypDeveloper 提问时间:11/17/2023 更新时间:11/21/2023 访问量:224
由于无法升级的不兼容包,无法安装新的 flutter 包
Unable to install new flutter packages because of incompatible packages that cannot be upgraded
问:
我正在尝试在我的 flutter 应用程序中安装 uuid 和 shared_preference 包,但我有三个包(meta、web 和 material_color_utilites)包已经过时,我无法更新它们。
以下是软件包的当前版本: http: ^1.1.0 uuid: ^4.2.1 shared_preferences: ^2.2.2 material_color_utilities: ^0.5.0 meta: ^1.10.0 web: ^0.3.0
这是我的 flutter 版本:Flutter 3.16.0 • channel stable • https://github.com/flutter/flutter.git Framework • revision db7ef5bf9f (2 days ago) • 2023-11-15 11:25:44 -0800 Engine • revision 74d16627b9 Tools • Dart 3.2.0 • DevTools 2.28.2
当我运行或出现此错误时:flutter pub get
flutter pub upgrade --major-versions
Resolving dependencies... (1.7s)
material_color_utilities 0.5.0 (0.8.0 available)
meta 1.10.0 (1.11.0 available)
web 0.3.0 (0.4.0 available)
No dependencies changed.
3 packages have newer versions incompatible with dependency constraints.
Try `flutter pub outdated` for more information.
当我运行时,我收到以下消息:flutter pub outdated
Showing outdated packages.
[*] indicates versions that are not the latest available.
Package Name Current Upgradable Resolvable Latest
direct dependencies:
material_color_utilities *0.5.0 *0.5.0 *0.5.0 0.8.0
meta *1.10.0 *1.10.0 *1.10.0 1.11.0
web *0.3.0 *0.3.0 *0.3.0 0.4.0
dev_dependencies: all up-to-date.
You are already using the newest resolvable versions listed in the 'Resolvable' column.
Newer versions, listed in 'Latest', may not be mutually compatible.
如果我尝试在 pubspec.yaml 文件中手动更改软件包的版本,我会收到此错误:
Resolving dependencies...
Note: web is pinned to version 0.3.0 by flutter_test from the flutter SDK.
See https://dart.dev/go/sdk-version-pinning for details.
Because every version of flutter_test from sdk depends on web 0.3.0 and screen_frontend depends on
web ^0.4.0, flutter_test from sdk is forbidden.
So, because screen_frontend depends on flutter_test from sdk, version solving failed.
You can try the following suggestion to make the pubspec resolve:
* Consider downgrading your constraint on web: flutter pub add web:^0.3.0
答:
flutter pub outdated
它说你的项目中有过时的包,你需要更新它
运行此命令,
flutter pub upgrade --major-versions
评论
flutter pub outdated
差不多的东西。
跑: flutter 更新包 --force-upgrade
https://github.com/dart-lang/sdk/wiki/Flutter-Pinned-Packages
https://github.com/flutter/flutter/blob/master/packages/flutter/pubspec.yaml
评论