转换URI为本地文件对象,解决相册/文件管理器资源访问的权限适配问题(Android ContentResolver封装)
uri_to_file
本项目基于 uri_to_file 开发。
1. 安装与使用
1.1 安装方式
进入到工程目录并在 pubspec.yaml 中添加以下依赖:
pubspec.yaml
...
dependencies:
uri_to_file:
git:
url: https://gitcode.com/OpenHarmony-Flutter/fluttertpc_uri_to_file
...
执行命令
flutter pub get
1.2 使用案例
使用案例详见 example
2. 约束与限制
2.1 兼容性
在以下版本中已测试通过
- Flutter: 3.22.1-ohos-1.0.3; SDK: 5.0.0(12); IDE: DevEco Studio: 6.0.1.251; ROM: 6.0.0.115 SP16;
- Flutter: 3.27.5-ohos-1.0.1; SDK: 5.0.0(12); IDE: DevEco Studio: 6.0.1.251; ROM: 6.0.0.115 SP16;
- Flutter: 3.35.8-ohos-0.0.2; SDK: 6.0.1(21); IDE: DevEco Studio: 6.0.1.260; ROM: 6.0.0.130 SP15;
3. API
"ohos Support"列为 yes 表示 ohos 平台支持该属性;no 则表示不支持;partially 表示部分支持。
| Name | Description | Type | Input | Output | ohos Support |
|---|---|---|---|---|---|
| toFile | 将URI转换为文件路径 | function | String | Future | yes |
| clearTemporaryFiles | 清除临时文件 | function | 无 | Future | yes |
4. 遗留问题
无
5. 开源协议
本项目基于 The MIT License,请自由地享受和参与开源。