HarmonyOS Flutter shared_preferences插件引用本地找不到文件路径以及文件

报错内容:

Compiling debug_ohos_application for the Ohos...
lib/src/basic/AnyCache.dart:1:8: Error: Error when reading '/C:/Users/Administrator/AppData/Local/Pub/Cache/git/flutter_packages-335b6f6f4620090a9bf503536e6af82d593fbb06/packages/shared_preferences/shared_preferences/lib/shared_preferences.dart': 系统找不到指定的路径。

pubspec.yaml插件引用如下:

shared_preferences:
  git:
  url: "https://gitee.com/openharmony-sig/flutter_packages.git"
  path: "packages/shared_preferences/shared_preferences"

帮忙看看是什么问题?

HarmonyOS
1天前
浏览
收藏 0
回答 1
待解决
回答 1
按赞同
/
按时间
superinsect

尝试添加dependency_overrides:

dependency_overrides:
  shared_preferences:
    git:
    url: "https://gitee.com/openharmony-sig/flutter_packages.git"
    path: "packages/shared_preferences/shared_preferences"

dependency_overrides和dependencies对齐原因,不对齐就会提示。

pub get failed
command: "D:\flutter\flutter\bin\cache\dart-sdk\bin\dart __deprecated_pub --directory . get --example"
pub env: {
  "FLUTTER_ROOT": "D:\flutter\flutter",
  "PUB_ENVIRONMENT": "flutter_cli:get",
  "PUB_CACHE": "C:\Users\Administrator\AppData\Local\Pub\Cache",
}
dependencies:
  flutter:
    sdk: flutter
cupertino_icons: ^1.0.2
dependency_overrides:
  shared_preferences:
    git:
    url: "https://gitee.com/openharmony-sig/flutter_packages.git"
    path: "packages/shared_preferences/shared_preferences" 

导入使用:

import 'package:shared_preferences_platform_interface/shared_preferences_platform_interface.dart';

使用demo:https://gitee.com/openharmony-sig/flutter_packages/tree/master/packages/shared_preferences/shared_preferences_ohos/example

分享
微博
QQ
微信
回复
1天前
相关问题
HarmonyOS 引用找不到方法
250浏览 • 1回复 待解决
Flutter如何调用本地插件
550浏览 • 1回复 待解决
flutter_sound 插件引用问题
506浏览 • 1回复 待解决
文件上传的本地路径如何获取
444浏览 • 1回复 待解决
DevEco Studio真机调试找不到签名文件
698浏览 • 1回复 待解决
Harmony 如何读取本地视频文件路径
14823浏览 • 2回复 待解决