由于无法升级的不兼容包,无法安装新的 flutter 包

Unable to install new flutter packages because of incompatible packages that cannot be upgraded

提问人:pypDeveloper 提问时间:11/17/2023 更新时间:11/21/2023 访问量:224

问:

我正在尝试在我的 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
颤振 飞镖

评论


答:

0赞 Ashok Kmr 11/18/2023 #1

flutter pub outdated它说你的项目中有过时的包,你需要更新它

运行此命令,

flutter pub upgrade --major-versions

评论

1赞 pypDeveloper 11/18/2023
我收到错误:正在解决依赖项...(1.6s) material_color_utilities 0.5.0 (0.8.0 可用) meta 1.10.0 (1.11.0 可用) > plugin_platform_interface 2.1.7 (原为 2.1.6) > shared_preferences_web 2.2.2 (原为 2.2.1) web 0.3.0 (0.4.0 可用) 更改了 2 个依赖项!3 个包具有与依赖项约束不兼容的较新版本。请尝试了解更多信息。pubspec.yaml 没有变化!flutter pub outdated
0赞 Ashok Kmr 11/21/2023
我认为您正在使用更高版本的依赖项,删除所有包并且您在发生错误之前已经添加,然后在添加包后没有提及版本,示例添加像 http: 不像 :http: ^1.1.0 ,, 喜欢使用 vscode 添加依赖项添加依赖项
1赞 pypDeveloper 11/22/2023
我收到同样的错误,即使我创建一个新项目并尝试安装新的依赖项,我也会遇到同样的错误,当我运行 flutter upgrade 时,它说我在最新版本上,不确定下一步该怎么做。
0赞 Falkner SPiT 12/5/2023 #2

差不多的东西。

跑: flutter 更新包 --force-upgrade

https://github.com/dart-lang/sdk/wiki/Flutter-Pinned-Packages

https://github.com/flutter/flutter/blob/master/packages/flutter/pubspec.yaml

评论

0赞 Community 12/9/2023
正如目前所写的那样,你的答案尚不清楚。请编辑以添加其他详细信息,以帮助其他人了解这如何解决所提出的问题。您可以在帮助中心找到有关如何写出好答案的更多信息。