Skip to content

Commit 4e0c197

Browse files
committed
📝 Improve documentation.
Fix #29 .
1 parent 6b6a46a commit 4e0c197

File tree

3 files changed

+230
-109
lines changed

3 files changed

+230
-109
lines changed

README-ZH.md

Lines changed: 101 additions & 50 deletions
Original file line numberDiff line numberDiff line change
@@ -13,17 +13,19 @@ Language: [English](README.md) | 中文简体
1313

1414
## 目录 🗂
1515

16-
* [特性](#特性-)
17-
* [截图](#截图-)
18-
* [准备工作](#准备工作-)
16+
* [特性](#特性-)
17+
* [截图 📸](#截图-📸)
18+
* [准备工作 🍭](#准备工作-🍭)
1919
* [Flutter](#flutter)
2020
* [Android](#android)
2121
* [iOS](#ios)
22-
* [使用方法](#使用方法-)
22+
* [使用方法 📖](#使用方法-📖)
2323
* [简单的使用方法](#简单的使用方法)
2424
* [完整参数的使用方法](#完整参数的使用方法)
2525
* [注册资源变化回调](#注册资源变化回调)
26-
* [常见问题](#常见问题)
26+
* [类介绍 💭](#类介绍-💭)
27+
* [`AssetEntity`](#assetentity)
28+
* [常见问题 ❔](#常见问题-❔)
2729
* [`File``Uint8List`创建`AssetEntity`的方法](#从file或uint8list创建assetentity的方法)
2830
* [控制台提示 'Failed to find GeneratedAppGlideModule'](#控制台提示-failed-to-find-generatedappglidemodule)
2931

@@ -48,7 +50,7 @@ Language: [English](README.md) | 中文简体
4850
| ![4](screenshots/4.jpg) | ![5](screenshots/5.jpg) | ![6](screenshots/6.jpg) |
4951
| ![7](screenshots/7.jpg) | ![8](screenshots/8.jpg) | ![9](screenshots/9.jpg) |
5052

51-
## 开始前的注意事项
53+
## 开始前的注意事项 ‼️
5254

5355
尽管该库提供了资源的选择,其仍然要求使用者构建自己的方法来处理显示、上传等操作。如果你在使用该库的过程对某些方法或API有疑问,请运行demo并查看[photo_manager](https://github.com/CaiJingLong/flutter_photo_manager)对相关方法的使用说明。
5456

@@ -142,11 +144,14 @@ rootProject.allprojects {
142144
| pathThumbSize | `int` | 选择器的缩略图大小 | 80 |
143145
| gridCount | `int` | 选择器网格数量 | 4 |
144146
| requestType | `RequestType` | 选择器选择资源的类型 | `RequestType.image` |
147+
| specialPickerType | `SpecialPickerType` | 提供一些特殊的选择器类型以整合非常规的选择行为 | `null` |
145148
| selectedAssets | `List<AssetEntity>` | 已选的资源。确保不重复选择。如果你允许重复选择,请将其置空。 | `null` |
146149
| themeColor | `Color` | 选择器的主题色 | `Color(0xff00bc56)` |
147150
| pickerTheme | `ThemeData` | 选择器的主题提供,包括查看器 | `null` |
148151
| sortPathDelegate | `SortPathDeleage` | 资源路径的排序实现,可自定义路径排序方法 | `CommonSortPathDelegate` |
149152
| textDelegate | `TextDelegate` | 选择器的文本代理构建,用于自定义文本 | `DefaultTextDelegate()` |
153+
| customItemBuilder | `WidgetBuilder` | 自定义item的构造方法 | `null` |
154+
| customItemPosition | `CustomItemPosition` | 允许用户在选择器中添加一个自定义item,并指定位置。 | `CustomItemPosition.none` |
150155
| routeCurve | `Curve` | 选择构造路由动画的曲线 | `Curves.easeIn` |
151156
| routeDuration | `Duration` | 选择构造路由动画的时间 | `const Duration(milliseconds: 500)` |
152157

@@ -166,49 +171,7 @@ AssetPicker.pickAsset(context).then((List<AssetEntity> assets) {
166171

167172
### 完整参数的使用方法
168173

169-
```dart
170-
List<AssetEntity> assets = <AssetEntity>[];
171-
172-
final List<AssetEntity> result = await AssetPicker.pickAssets(
173-
context,
174-
maxAssets: 9,
175-
pageSize: 320,
176-
pathThumbSize: 80,
177-
gridCount: 4,
178-
requestType: RequestType.image,
179-
selectedAssets: assets,
180-
themeColor: Colors.cyan,
181-
pickerTheme: ThemeData.dark(), // 不能跟`themeColor`同时设置
182-
textDelegate: DefaultTextDelegate(),
183-
sortPathDelegate: CommonSortPathDelegate(),
184-
routeCurve: Curves.easeIn,
185-
routeDuration: const Duration(milliseconds: 500),
186-
);
187-
```
188-
189-
或者
190-
191-
```dart
192-
List<AssetEntity> assets = <AssetEntity>[];
193-
194-
AssetPicker.pickAssets(
195-
context,
196-
maxAssets: 9,
197-
pageSize: 320,
198-
pathThumbSize: 80,
199-
gridCount: 4,
200-
requestType: RequestType.image,
201-
selectedAssets: assets,
202-
themeColor: Colors.cyan,
203-
pickerTheme: ThemeData.dark(), // 不能跟`themeColor`同时设置
204-
textDelegate: DefaultTextDelegate(),
205-
sortPathDelegate: CommonSortPathDelegate(),
206-
routeCurve: Curves.easeIn,
207-
routeDuration: const Duration(milliseconds: 500),
208-
).then((List<AssetEntity> assets) {
209-
/.../
210-
});
211-
```
174+
欲了解各种选择器模式,请直接运行 example 查看。
212175

213176
### 注册资源变化回调
214177
```dart
@@ -218,7 +181,95 @@ AssetPicker.registerObserve(); // 注册回调
218181
AssetPicker.unregisterObserve(); // 取消注册回调
219182
```
220183

221-
## 常见问题
184+
## 类介绍 💭
185+
186+
### `AssetEntity`
187+
188+
```dart
189+
/// Android: Database _id column
190+
/// iOS : `PhotoKit > PHObject > localIdentifier`
191+
String id;
192+
193+
/// Android: `MediaStore.MediaColumns.DISPLAY_NAME`
194+
/// iOS : `PHAssetResource.filename`. Nullable
195+
/// If you must need it, See [FilterOption.needTitle] or use [titleAsync].
196+
String title;
197+
198+
/// Android: title
199+
/// iOS : [PHAsset valueForKey:@"filename"]
200+
Future<String> get titleAsync;
201+
202+
/// * 1: [AssetType.image]
203+
/// * 2: [AssetType.video]
204+
/// * 3: [AssetType.audio]
205+
/// * default: [AssetType.other]
206+
AssetType get type;
207+
208+
/// Asset type int value.
209+
int typeInt;
210+
211+
/// Duration of video, the unit is second.
212+
/// If [type] is [AssetType.image], then it's value is 0.
213+
/// See also: [videoDuration].
214+
int duration;
215+
216+
/// Width of the asset.
217+
int width;
218+
219+
/// Height of the asset.
220+
int height;
221+
222+
/// Location information when shooting. Nullable.
223+
/// When the device is Android 10 or above, it's ALWAYS null.
224+
/// See also: [longitude].
225+
double get latitude => _latitude ?? 0;
226+
/// Also with a setter.
227+
228+
/// Get lat/lng from `MediaStore`(Android) / `Photos`(iOS).
229+
/// In Android Q, this comes from EXIF.
230+
Future<LatLng> latlngAsync();
231+
232+
/// Get [File] object.
233+
/// Notice that this is not the origin file, so when it comes to some
234+
/// scene like reading a GIF's file, please use `originFile`, or you'll
235+
/// get a JPG.
236+
Future<File> get file async;
237+
238+
/// Get the original [File] object.
239+
Future<File> get originFile async;
240+
241+
/// The raw data for the entity, it may be large.
242+
/// This property is NOT RECOMMENDED for video assets.
243+
Future<Uint8List> get originBytes;
244+
245+
/// The thumbnail data for the entity. Usually use for displaying a thumbnail image widget.
246+
Future<Uint8List> get thumbData;
247+
248+
/// Get thumbnail data with specific size.
249+
Future<Uint8List> thumbDataWithSize(
250+
int width,
251+
int height, {
252+
ThumbFormat format = ThumbFormat.jpeg,
253+
int quality = 100,
254+
});
255+
256+
/// Get the asset's size. Nullable if the manager is null,
257+
Size get size;
258+
259+
/// If the asset is deleted, return false.
260+
Future<bool> get exists => PhotoManager._assetExistsWithId(id);
261+
262+
/// The url is provided to some video player. Such as [flutter_ijkplayer](https://pub.dev/packages/flutter_ijkplayer)
263+
///
264+
/// Android: `content://media/external/video/media/894857`
265+
/// iOS : `file:///var/mobile/Media/DCIM/118APPLE/IMG_8371.MOV` in iOS.
266+
Future<String> getMediaUrl();
267+
268+
/// Refresh the properties for the entity.
269+
Future<AssetEntity> refreshProperties() async;
270+
```
271+
272+
## 常见问题 ❔
222273

223274
### `File``Uint8List`创建`AssetEntity`的方法
224275

0 commit comments

Comments
 (0)