Skip to content

Commit fa25b72

Browse files
committed
📝 Update README with workaround with create AssetEntity. Close #9 .
1 parent b94b8c9 commit fa25b72

File tree

2 files changed

+38
-6
lines changed

2 files changed

+38
-6
lines changed

README-ZH.md

Lines changed: 19 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -8,7 +8,7 @@
88

99
Language: [English](README.md) | 中文简体
1010

11-
对标微信的资源选择器,基于`photo_manager`实现资源相关功能,`extended_image`用于查看图片,`provider`用于协助管理选择器的状态。
11+
对标微信的**资源选择器**,基于`photo_manager`实现资源相关功能,`extended_image`用于查看图片,`provider`用于协助管理选择器的状态。
1212

1313
## 目录 🗂
1414

@@ -32,13 +32,12 @@ Language: [English](README.md) | 中文简体
3232
## 目标TODO 📅
3333

3434
- [x] 图片资源支持
35-
- [ ] 图片编辑(裁剪/旋转/涂鸦)
3635
- [x] 视频资源支持
37-
- [ ] 视频编辑
3836
- [ ] 音频资源支持
3937
- [ ] 单资源模式
4038
- [x] 国际化支持
4139
- [x] 自定义文本支持
40+
- [x] 完整的自定义主题
4241
- [ ] FFW支持
4342

4443
## 截图 📸
@@ -158,3 +157,20 @@ AssetPicker.pickAssets(
158157
});
159158
```
160159

160+
### `File``Uint8List`创建`AssetEntity`的方法
161+
162+
如果需要使用此库结合一些拍照需求,可通过以下方法将`File``Uint8List`转为`AssetEntity`
163+
164+
```dart
165+
final File file = your_file; // 你的File对象
166+
final Uint8List byteData = await file.readAsBytes(); // 转为Uint8List
167+
final AssetEntity imageEntity = await PhotoManager.editor.saveImage(byteData); // 存入手机并生成AssetEntity
168+
```
169+
170+
如果不想保留文件,可以在操作完成(上传完或业务处理完)后进行删除:
171+
172+
```dart
173+
final List<String> result = await PhotoManager.editor.deleteWithIds([entity.id]);
174+
```
175+
176+
参考文档: [flutter_photo_manager#insert-new-item](https://github.com/CaiJingLong/flutter_photo_manager#insert-new-item)

README.md

Lines changed: 19 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -8,7 +8,7 @@
88

99
Language: English | [中文简体](README-ZH.md)
1010

11-
An assets picker which looks like the one in WeChat, based on `photo_manager` for asset implementation, `extended_image` for image preview, `provider` to help controlling the state of the picker.
11+
An **assets picker** which looks like the one in WeChat, based on `photo_manager` for asset implementation, `extended_image` for image preview, `provider` to help controlling the state of the picker.
1212

1313
## Category 🗂
1414

@@ -32,13 +32,12 @@ An assets picker which looks like the one in WeChat, based on `photo_manager` fo
3232
## TODO 📅
3333

3434
- [x] Image asset support
35-
- [ ] Image editing (Cut/Rotate/Draw)
3635
- [x] Video asset support
37-
- [ ] Video editing support
3836
- [ ] Audio asset support
3937
- [ ] Single asset mode
4038
- [x] i18n support
4139
- [x] Custom text delegate support
40+
- [x] Custom theming entirely
4241
- [ ] Flutter For the Web support
4342

4443
## Screenshots 📸
@@ -155,3 +154,20 @@ AssetPicker.pickAssets(
155154
});
156155
```
157156

157+
### Create `AssetEntity` from `File` or `Uint8List` (rawData)
158+
159+
In order to combine this package with camera shooting or something related, there's a wordaround about how to create an `AssetEntity` with `File` or `Uint8List` object.
160+
161+
```dart
162+
final File file = your_file; // Your file object
163+
final Uint8List byteData = await file.readAsBytes(); // Convert to Uint8List
164+
final AssetEntity imageEntity = await PhotoManager.editor.saveImage(byteData); // Saved in the device then create an AssetEntity
165+
```
166+
167+
If you don't want to keep the asset in your device, just delete it after you complete with your process (upload, editing, etc).
168+
169+
```dart
170+
final List<String> result = await PhotoManager.editor.deleteWithIds([entity.id]);
171+
```
172+
173+
ref: [flutter_photo_manager#insert-new-item](https://github.com/CaiJingLong/flutter_photo_manager#insert-new-item)

0 commit comments

Comments
 (0)