image_size_getter 安装错误(因为来自 sdk 的 flutter_test 的每个版本都依赖于集合 [...])[flutter]

image_size_getter install error (Because every version of flutter_test from sdk depends on collection [...]) [flutter]

我正在尝试在我的 flutter 桌面项目上安装 image-size-getter

当我将它添加到我的包裹时 pubspec.yaml:

dependencies:
  [...]
  image_size_getter: ^0.1.0

我收到这个错误:

Because every version of flutter_test from sdk depends on collection 1.14.11 and every version of image_size_getter depends on collection ^1.14.12, flutter_test from sdk is incompatible with image_size_getter. So, because example_flutter depends on both image_size_getter ^0.1.0 and flutter_test any from sdk, version solving failed.

我试图通过验证依赖关系来解决这个问题,因为我发现 and (我必须在 futter 主频道上):

dependency_overrides:
  flutter_test: ^1.14.12

但是现在好像没有flutter_test包:

Because example_flutter depends on flutter_test any which doesn't exist (could not find package flutter_test at https://pub.dartlang.org), version solving failed. pub get failed (server unavailable) -- attempting retry 1 in 1 second... Because example_flutter depends on flutter_test any which doesn't exist (could not find package flutter_test at https://pub.dartlang.org), version solving failed. pub get failed (server unavailable) -- attempting retry 2 in 2 seconds... Because example_flutter depends on flutter_test any which doesn't exist (could not find package flutter_test at https://pub.dartlang.org), version solving failed. pub get failed (server unavailable) -- attempting retry 3 in 4 seconds... [..]

我升级到上一个 master 频道版本,这是我的 flutter doctor 输出:

    PS C:\flutter0229_flutter-desktop-embedding-master\example> flutter doctor
    Doctor summary (to see all details, run flutter doctor -v):
    [√] Flutter (Channel master, v1.15.4-pre.239, on Microsoft Windows [Versione 10.0.18362.657], locale it-IT)

    [√] Android toolchain - develop for Android devices (Android SDK version 28.0.3)
    [√] Visual Studio - develop for Windows (Visual Studio Community 2019 16.4.3)
    [√] Android Studio (version 3.0)
    [√] IntelliJ IDEA Ultimate Edition (version 2017.2)
    [√] VS Code, 64-bit edition (version 1.42.1)
    [√] Connected device (1 available)

No issues found! 

我该如何解决我的问题?

flutter_test 不是您可以为其覆盖版本的常规包 - 它是 Flutter SDK 的一部分。

然而,您可以做的是覆盖 collection 的版本,这样 flutter_testimage_size_getter 使用相同的版本并且不再冲突。

试试这个:

dependency_overrides:
  collection: ^1.14.12

更新您最新的 collection 插件

dependencies:
 collection: ^1.14.13