首页 > 解决方案 > 为什么依赖项覆盖在颤振中不能按预期工作?

问题描述

我想强制我的项目使用hooks_riverpodversion 1.0.0-dev.6,所以我在 pubspect.yaml 中指定依赖项,如下所示:

dependencies:
  hooks_riverpod: 1.0.0-dev.6
dependency_overrides:
  hooks_riverpod: 1.0.0-dev.6

但是当我编译项目时,依赖项仍然使用另一个版本1.0.0-dev.10

../../../.pub-cache/hosted/pub.dartlang.org/riverpod-1.0.0-dev.10/lib/src/async_value_converters.dart:223:39: Error: The method 'ignore' isn't defined for the class 'Future<State>'.
 - 'Future' is from 'dart:async'.
Try correcting the name to the name of an existing method, or defining a method named 'ignore'.
            loadingCompleter!.future..ignore(),

我错过了什么吗?我应该怎么做才能使用版本强制颤振依赖1.0.0-dev.6?顺便说一句,我已经跑flutter update/upgrade/outdate了很多次了。我还尝试删除 pub-cache 文件夹并重新下载依赖包。我发现 .packages 文件总是自动生成这一行:

riverpod:file:///Users/dolphin/.pub-cache/hosted/pub.dartlang.org/riverpod-1.0.0-dev.10/lib/

这是我的颤振版本信息:

$ ~/apps/flutter/bin/flutter doctor                                                                                                         ‹ruby-2.7.2›
Doctor summary (to see all details, run flutter doctor -v):
[✓] Flutter (Channel stable, 2.2.3, on macOS 11.2.3 20D91 darwin-x64, locale en-CN)
[✓] Android toolchain - develop for Android devices (Android SDK version 30.0.3)
[✓] Xcode - develop for iOS and macOS
[✓] Chrome - develop for the web
[!] Android Studio (version 2020.3)
    ✗ Unable to find bundled Java version.
[✓] IntelliJ IDEA Ultimate Edition (version 2021.2.2)
[✓] VS Code (version 1.60.2)
[✓] Connected device (3 available)
    ! Error: xiaoqiang 的 iPhone is not connected. Xcode will continue when xiaoqiang 的 iPhone is connected. (code -13)

! Doctor found issues in 1 category.
(base)

标签: flutter

解决方案


推荐阅读