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

如何解决flutter_web_plugins包找不到导致的pub get失败问题?

解决Flutter依赖flutter_web_plugins导致的pub get失败问题

问题原因

flutter_web_plugins并非pub.dev官方仓库的包,而是来自第三方私有源https://pub.mpflutter.com。默认情况下pub只会从pub.dev拉取依赖,因此无法找到该包引发版本解析失败。

解决步骤

1. 明确指定依赖的源地址

修改项目根目录的pubspec.yaml文件,将flutter_web_plugins的依赖声明改为指定私有源的形式:

dependencies:
  # 其他依赖保持不变
  flutter_web_plugins:
    hosted:
      name: flutter_web_plugins
      url: https://pub.mpflutter.com
    version: "1.2.1" # 或保留any,但指定具体版本更稳定

如果项目中已有dependency_overrides,也可以通过覆盖配置来指定源:

dependency_overrides:
  flutter_web_plugins:
    hosted:
      name: flutter_web_plugins
      url: https://pub.mpflutter.com
    version: "1.2.1"

2. 清理缓存并重新拉取依赖

  • 删除项目根目录下的pubspec.lock文件
  • 执行命令清理pub缓存:
    flutter pub cache clean
    
  • 重新执行依赖拉取:
    flutter pub get
    

3. (可选)检查系统级pub配置

如果上述步骤仍未解决,可检查系统级pub配置是否包含该私有源的访问权限:

  • 找到pub配置文件(Mac/Linux路径为~/.pub-cache/credentials.json,Windows路径为C:\Users\<你的用户名>\AppData\Roaming\Pub\Cache\credentials.json)
  • 确认文件中是否有对应私有源的配置,若没有可联系私有源管理员获取配置方式。

内容的提问来源于stack exchange,提问作者Liu Anlong - 刘安龙

相关产品推荐
方舟 Agent Plan

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

最近更新时间:2026.07.16 01:12:02