执行flutter pub get失败,依赖配置及路径错误求助
解决flutter_blue_plus example依赖错误的步骤
错误1:pubspec.yaml依赖来源冲突
pubspec.yaml第13行第5列错误:一个依赖只能有一个来源。
╷
13 │ ┌ sdk: flutter
14 │ │
15 │ │
16 │ │ # Note: We use a path dependency because the example app & plugin are bundled together.
17 │ │ # In your app you should use ^1.17.3 or similar
18 │ │ path: ../
19 │ └
╵
处理方法:
- 打开
C:\Users\Lokman\Downloads\flutter_blue_plus-1.35.3\example\pubspec.yaml文件 - 找到第13行开始的flutter_blue_plus依赖块,删除
sdk: flutter这一行,只保留path: ../,修改后该块内容如下:
flutter_blue_plus: # Note: We use a path dependency because the example app & plugin are bundled together. # In your app you should use ^1.17.3 or similar path: ../
错误2:flutter_blue_plus_web路径不存在
正在解析依赖项...
由于flutter_blue_plus_example依赖的flutter_blue_plus_web路径不存在(无法在"../../flutter_blue_plus_web"找到该包),版本解析失败。
包更新失败。
处理方法:
检查源码包完整性:
- 打开
C:\Users\Lokman\Downloads\flutter_blue_plus-1.35.3目录,确认是否存在flutter_blue_plus_web文件夹 - 如果没有这个文件夹,说明下载的源码包不完整,重新下载flutter_blue_plus 1.35.3的完整源码包
- 打开
修正路径配置:
- 如果确认存在
flutter_blue_plus_web文件夹,打开example目录下的pubspec.yaml,找到flutter_blue_plus_web的依赖配置 - 将原路径
../../flutter_blue_plus_web修改为../flutter_blue_plus_web(example目录的上级就是根目录,向上一级即可找到该文件夹)
- 如果确认存在
最后验证
修改完成后,回到example目录的终端,重新执行:
flutter pub get
如果没有报错,说明依赖配置已修复。
内容的提问来源于stack exchange,提问作者HobiSoft
相关产品推荐
相关产品推荐

