我正在try 安装Ffltter_riverpod,但它按照安装包的常规方法给出了这些错误消息.这是来自pub.dev的

我在我的依赖项下添加了flutter_riverpod: ^1.0.4个,但给出了一个错误

Because riverpod depends on flutter_riverpod ^1.0.4 which depends on riverpod 1.0.3, riverpod 1.0.3 is required.
So, because riverpod is 1.0.0+1, version solving failed.
pub get failed (1; So, because riverpod is 1.0.0+1, version solving failed.)
exit code 1

下面是我的pubspec.yaml文件

name: riverpod
description: A new Flutter project.

# The following line prevents the package from being accidentally published to
# pub.dev using `flutter pub publish`. This is preferred for private packages.
publish_to: 'none' # Remove this line if you wish to publish to pub.dev

# The following defines the version and build number for your application.
# A version number is three numbers separated by dots, like 1.2.43
# followed by an optional build number separated by a +.
# Both the version and the builder number may be overridden in flutter
# build by specifying --build-name and --build-number, respectively.
# In Android, build-name is used as versionName while build-number used as versionCode.
# Read more about Android versioning at https://developer.android.com/studio/publish/versioning
# In iOS, build-name is used as CFBundleShortVersionString while build-number is used as CFBundleVersion.
# Read more about iOS versioning at
# https://developer.apple.com/library/archive/documentation/General/Reference/InfoPlistKeyReference/Articles/CoreFoundationKeys.html
# In Windows, build-name is used as the major, minor, and patch parts
# of the product and file versions while build-number is used as the build suffix.
version: 1.0.0+1

environment:
  sdk: '>=2.18.1 <3.0.0'

# Dependencies specify other packages that your package needs in order to work.
# To automatically upgrade your package dependencies to the latest versions
# consider running `flutter pub upgrade --major-versions`. Alternatively,
# dependencies can be manually updated by changing the version numbers below to
# the latest version available on pub.dev. To see which dependencies have newer
# versions available, run `flutter pub outdated`.
dependencies:
  flutter:
    sdk: flutter


  # The following adds the Cupertino Icons font to your application.
  # Use with the CupertinoIcons class for iOS style icons.
  cupertino_icons: ^1.0.2
  flutter_riverpod: ^1.0.4

dev_dependencies:
  flutter_test:
    sdk: flutter

  # The "flutter_lints" package below contains a set of recommended lints to
  # encourage good coding practices. The lint set provided by the package is
  # activated in the `analysis_options.yaml` file located at the root of your
  # package. See that file for information about deactivating specific lint
  # rules and activating additional ones.
  flutter_lints: ^2.0.0

# For information on the generic Dart part of this file, see the
# following page: https://dart.dev/tools/pub/pubspec

# The following section is specific to Flutter packages.
flutter:

  # The following line ensures that the Material Icons font is
  # included with your application, so that you can use the icons in
  # the material Icons class.
  uses-material-design: true

  # To add assets to your application, add an assets section, like this:
  # assets:
  #   - images/a_dot_burr.jpeg
  #   - images/a_dot_ham.jpeg

  # An image asset can refer to one or more resolution-specific "variants", see
  # https://flutter.dev/assets-and-images/#resolution-aware

  # For details regarding adding assets from package dependencies, see
  # https://flutter.dev/assets-and-images/#from-packages

  # To add custom fonts to your application, add a fonts section here,
  # in this "flutter" section. Each entry in this list should have a
  # "family" key with the font family name, and a "fonts" key with a
  # list giving the asset and other descriptors for the font. For
  # example:
  # fonts:
  #   - family: Schyler
  #     fonts:
  #       - asset: fonts/Schyler-Regular.ttf
  #       - asset: fonts/Schyler-Italic.ttf
  #         style: italic
  #   - family: Trajan Pro
  #     fonts:
  #       - asset: fonts/TrajanPro.ttf
  #       - asset: fonts/TrajanPro_Bold.ttf
  #         weight: 700
  #
  # For details regarding fonts from package dependencies,
  # see https://flutter.dev/custom-fonts/#from-packages

这也是《Flutter doctor 》跑的结果

Doctor summary (to see all details, run flutter doctor -v):
[✓] Flutter (Channel stable, 3.3.2, on Ubuntu 22.04.1 LTS 5.15.0-47-generic, locale en_US.UTF-8)
[✓] Android toolchain - develop for Android devices (Android SDK version 33.0.0)
[✓] Chrome - develop for the web
[✓] Linux toolchain - develop for Linux desktop
[✓] Android Studio (version 2021.2)
[✓] VS Code
[✓] Connected device (3 available)
[✓] HTTP Host Availability

• No issues found!

推荐答案

您的具体问题是因为您的项目名为Riverpod.它与hooks_riverpod和fltter_riverpod的riverpod依赖项冲突.重命名您的项目,它将会起作用.

来源:Version solving failing on running "flutter pub get" for Riverpod with the new Flutter 2.2.2 verison

Flutter相关问答推荐

如何在SingleChildScrollView中使用GridView

Flutter:如何从Bottom Navigator中删除此内容

我如何才能收到每天重复的预定通知?

从Flutter应用程序解释蓝牙BLE数据:了解Sylvania压力值

try 在Flutter应用程序中传递变量到FirebaseFirestore Where子句

如何使用底部导航栏修复此导航问题

Riverpod状态管理-在调用请求时更新用户界面

为什么Build_Runner的输出为0?

使用 Flutter 显示/隐藏带有下拉抽屉动画的小部件

Flutter http 请求获取 null

如何动态获取任何小部件的像素?

如何从Firebase登录获取用户信息,如电话号码、出生日期和性别

如何正确地将 PageView 设置为 AppBar 的标题?

如何解决需要一个标识符,但得到的是:.try 在:之前插入一个标识符.dart 错误

MediaQuery 在不同手机上不一致

在 Flutter 中使用 HardwareKeyboard 时所有键都没有响应

flutter - 无法解析 JSON 消息:文档为空

我想在一个屏幕上有两个相同区域的列表视图,我该如何设置?

如何修复int类型不是String类型的子类型

如何在 flutter 中更改日期 Select 器 colored颜色 ?