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

Flutter项目添加Riverpod依赖时pub get失败,求解决方案

Flutter项目添加Riverpod依赖时pub get版本冲突的解决方案

问题说明

首次给Flutter项目添加Riverpod依赖,执行flutter pub get时触发版本解析失败,错误核心是riverpod_lint ^2.3.12与SDK内置的flutter_test存在依赖冲突:

注意:Flutter SDK中的flutter_test将meta固定为1.11.0版本。
由于riverpod_lint >=2.3.12 <3.0.0-dev.0依赖analyzer ^6.5.0,而analyzer依赖meta ^1.14.0,因此riverpod_lint >=2.3.12 <3.0.0-dev.0需要meta ^1.14.0。
而SDK中所有版本的flutter_test都依赖meta 1.11.0,因此riverpod_lint >=2.3.12 <3.0.0-dev.0与SDK中的flutter_test不兼容。
由于项目riverpod_basics同时依赖SDK中的flutter_test和riverpod_lint ^2.3.12,版本解析失败。

解决方法

直接降低riverpod_lint的版本约束即可解决冲突,操作步骤如下:

  1. 执行命令更新依赖版本:
flutter pub add dev:riverpod_lint:^2.3.10
  1. 修改后的dev_dependencies配置示例:
dev_dependencies:
  flutter_test:
    sdk: flutter

  flutter_lints: ^3.0.0
  custom_lint:
  riverpod_lint: ^2.3.10
  1. 重新执行flutter pub get完成依赖安装。

内容的提问来源于stack exchange,提问作者Bob-Daawid Nwobodo

相关产品推荐
方舟 Agent Plan

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

最近更新时间:2026.06.24 02:12:36