升级了flutter版本后,运行flutter后提示错误 Because every version of flutter from sdk depends on characters 1.2.1 which doesn't match any versions, flutter from sdk is forbidden.

升级了flutter版本后,运行flutter后提示错误

Because every version of flutter from sdk depends on characters 1.2.1 which doesn’t match any versions, flutter from sdk is forbidden.

解决方法:

增加了:

dependency_overrides:

  characters: ">=1.0.0 <=1.2.1"
相关文档:
https://www.cnblogs.com/mengqd/p/13928830.html
依赖覆盖
想象如下场景:项目依赖一个库(比如 path_provider)的版本为 1.6.22,而另一个依赖库也依赖这个 path_provider, 但版本为 0.5.0,那么我最终到底依赖哪个版本,此时执行 flutter pub get 则会出现如下错误:
Running "flutter pub get" in flutter_app...                     

Because every version of flutter_plugin from path depends on path_provider ^0.5.0 and flutter_app depends on path_provider ^1.6.22, flutter_plugin from path is forbidden.
So, because flutter_app depends on flutter_plugin from path, version solving failed.
pub get failed (1; So, because flutter_app depends on flutter_plugin from path, version solving failed.)
Process finished with exit code 1
 
此时要解决这个冲突,可以添加 dependency_overrides:
dependency_overrides:
  path_provider: ^1.6.22
添加此属性后,所有 path_provider 插件都会使用同一个最新版本,使用此字段执行 flutter pub get 则会出现如下警告:
/Users/mengqingdong/project/flutter/bin/flutter --no-color pub get
Running "flutter pub get" in flutter_app...                     

Warning: You are using these overridden dependencies:
! path_provider 1.6.22
Running "flutter pub get" in flutter_app...                         0.5s
Process finished with exit code 0
 
赞(0) 打赏
分享到: 更多 (0)

觉得文章有用就打赏一下文章作者

支付宝扫一扫打赏

微信扫一扫打赏