使用image_gallery_saver_plus实现图库保存功能。
| Files | Last commit | Last update |
|---|---|---|
| 2 months ago | ||
| 2 months ago | ||
| 6 months ago | ||
| 6 months ago | ||
| 6 months ago | ||
| 6 months ago | ||
| 6 months ago | ||
| 1 month ago | ||
| 6 months ago | ||
| 2 years ago | ||
| 4 months ago | ||
| 1 month ago | ||
| 1 month ago | ||
| 6 months ago | ||
| 2 years ago | ||
| 4 months ago | ||
| 6 months ago |
image_gallery_saver_plus
本项目基于 image_gallery_saver_plus 开发。
1. 安装与使用
1.1 安装方式
进入到工程目录并在 pubspec.yaml 中添加以下依赖:
pubspec.yaml
...
dependencies:
image_gallery_saver_plus:
git:
url: https://gitcode.com/CPF-Flutter/fluttertpc_image_gallery_saver_plus.git
# ref: 根据下方表格选择不同框架适配的TAG版本
ref: x.x.x-ohos-x.x.x
...
执行命令
flutter pub get
TAG 命名规则:
原库版本-ohos.版本号,不同 TAG 之间的变更详见 CHANGELOG.OpenHarmony.md。
| Flutter框架版本 | TAG名称 | 分支名 |
|---|---|---|
| 3.7 | - | - |
| 3.22 | 3.0.5-ohos-1.0.0 | br_3.22 |
| 3.27 | 3.0.5-ohos-1.0.0 | br_3.22 |
| 3.35 | 3.0.5-ohos-1.0.0 | br_3.22 |
1.2 使用案例
使用案例详见 example
2. 约束与限制
2.1 兼容性
在以下版本中已测试通过
- Flutter: 3.22.1-ohos-1.0.1; SDK: 5.0.0(12); IDE: DevEco Studio: 5.1.0.828; ROM: 5.1.0.130 SP8;
- Flutter: 3.35.7-ohos-0.0.1; SDK: 6.0.1(21); IDE: DevEco Studio: 6.0.1.260; ROM: 6.0.0.120 SP6;
3. API
"ohos Support"列为 yes 表示 ohos 平台支持该属性;no 则表示不支持;partially 表示部分支持。使用方法跨平台一致,效果对标 iOS 或 Android 的效果。
| Name | Description | Type | Input | Output | ohos Support |
|---|---|---|---|---|---|
| saveImage | 将原始图像字节保存到设备媒体库 | function | Uint8List imageBytes, {int quality = 80, String? name, bool isReturnImagePathOfIOS = false} | FutureOr | yes |
| saveFile | 将图片文件或视频文件保存到设备媒体库 | function | String file, {String? name, bool isReturnPathOfIOS = false} | Future | yes |
4. 属性
"ohos Support"列为 yes 表示 ohos 平台支持该属性;no 则表示不支持;partially 表示部分支持。
saveImage 参数
| Name | Description | Type | Input | Output | ohos Support |
|---|---|---|---|---|---|
| imageBytes | 要保存的原始图像数据 | Uint8List | required | / | yes |
| quality | 图片压缩质量(0-100) | int | 80 | / | yes |
| name | 可选的文件名 | String? | null | / | yes |
| isReturnImagePathOfIOS | iOS 上是否返回保存的图片路径 | bool | false | / | no |
saveFile 参数
| Name | Description | Type | Input | Output | ohos Support |
|---|---|---|---|---|---|
| file | 设备上的图像或视频文件路径 | String | required | / | yes |
| name | 可选的文件名 | String? | null | / | yes |
| isReturnPathOfIOS | iOS 上是否返回保存的文件路径 | bool | false | / | no |
5. 遗留问题
6. 补充说明
7. 开源协议
本项目基于 The MIT License (MIT) ,请自由地享受和参与开源。