You need to enable JavaScript to run this app.
优惠活动
大模型
产品
解决方案
定价
更多

无法安装新Flutter包:依赖包版本不兼容且无法升级

Flutter依赖升级受阻:meta、web、material_color_utilities无法更新

当前环境与依赖版本

  • Flutter版本:
Flutter 3.16.0 • channel stable • https://github.com/flutter/flutter.git
Framework • revision db7ef5bf9f (2天前) • 2023-11-15 11:25:44 -0800
Engine • revision 74d16627b9
Tools • Dart 3.2.0 • DevTools 2.28.2
  • 当前项目依赖版本:
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 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中这三个包的版本为最新版后,执行flutter pub get出现如下错误:

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 SDK(如flutter_test)间接依赖并固定版本的,当前稳定版Flutter 3.16.0与这些包的现有版本完全兼容,强行升级会打破依赖约束,导致编译失败。
  • 等待Flutter SDK更新:后续Flutter稳定版迭代时,会同步升级这些依赖包的版本约束,届时执行flutter pub upgrade即可自动更新到兼容的最新版。
  • 临时切换开发通道(谨慎操作):如果必须使用这些包的最新版本,可以尝试切换到Flutter的beta或dev通道(注意:开发通道可能存在稳定性问题),执行命令:
flutter channel beta
flutter upgrade

之后再尝试更新依赖。

内容的提问来源于stack exchange,提问作者pypDeveloper

相关产品推荐
方舟 Agent Plan

超全模态模型 × Harness 升级,最新支持 Deepseek-V4.1-Flash、GLM-5.3 系列、Doubao-Seedream-5.0-pro、Kimi-K3 (部分), 限时 9.9 元起

最近更新时间:2026.07.06 03:42:44