@@ -13,17 +13,19 @@ Language: [English](README.md) | 中文简体
13
13
14
14
## 目录 🗂
15
15
16
- * [ 特性] ( #特性- )
17
- * [ 截图] ( #截图- )
18
- * [ 准备工作] ( #准备工作- )
16
+ * [ 特性 ✨ ] ( #特性-✨ )
17
+ * [ 截图 📸 ] ( #截图-📸 )
18
+ * [ 准备工作 🍭 ] ( #准备工作-🍭 )
19
19
* [ Flutter] ( #flutter )
20
20
* [ Android] ( #android )
21
21
* [ iOS] ( #ios )
22
- * [ 使用方法] ( #使用方法- )
22
+ * [ 使用方法 📖 ] ( #使用方法-📖 )
23
23
* [ 简单的使用方法] ( #简单的使用方法 )
24
24
* [ 完整参数的使用方法] ( #完整参数的使用方法 )
25
25
* [ 注册资源变化回调] ( #注册资源变化回调 )
26
- * [ 常见问题] ( #常见问题 )
26
+ * [ 类介绍 💭] ( #类介绍-💭 )
27
+ * [ ` AssetEntity ` ] ( #assetentity )
28
+ * [ 常见问题 ❔] ( #常见问题-❔ )
27
29
* [ 从` File ` 或` Uint8List ` 创建` AssetEntity ` 的方法] ( #从file或uint8list创建assetentity的方法 )
28
30
* [ 控制台提示 'Failed to find GeneratedAppGlideModule'] ( #控制台提示-failed-to-find-generatedappglidemodule )
29
31
@@ -48,7 +50,7 @@ Language: [English](README.md) | 中文简体
48
50
| ![ 4] ( screenshots/4.jpg ) | ![ 5] ( screenshots/5.jpg ) | ![ 6] ( screenshots/6.jpg ) |
49
51
| ![ 7] ( screenshots/7.jpg ) | ![ 8] ( screenshots/8.jpg ) | ![ 9] ( screenshots/9.jpg ) |
50
52
51
- ## 开始前的注意事项
53
+ ## 开始前的注意事项 ‼️
52
54
53
55
尽管该库提供了资源的选择,其仍然要求使用者构建自己的方法来处理显示、上传等操作。如果你在使用该库的过程对某些方法或API有疑问,请运行demo并查看[ photo_manager] ( https://github.com/CaiJingLong/flutter_photo_manager ) 对相关方法的使用说明。
54
56
@@ -142,11 +144,14 @@ rootProject.allprojects {
142
144
| pathThumbSize | ` int ` | 选择器的缩略图大小 | 80 |
143
145
| gridCount | ` int ` | 选择器网格数量 | 4 |
144
146
| requestType | ` RequestType ` | 选择器选择资源的类型 | ` RequestType.image ` |
147
+ | specialPickerType | ` SpecialPickerType ` | 提供一些特殊的选择器类型以整合非常规的选择行为 | ` null ` |
145
148
| selectedAssets | ` List<AssetEntity> ` | 已选的资源。确保不重复选择。如果你允许重复选择,请将其置空。 | ` null ` |
146
149
| themeColor | ` Color ` | 选择器的主题色 | ` Color(0xff00bc56) ` |
147
150
| pickerTheme | ` ThemeData ` | 选择器的主题提供,包括查看器 | ` null ` |
148
151
| sortPathDelegate | ` SortPathDeleage ` | 资源路径的排序实现,可自定义路径排序方法 | ` CommonSortPathDelegate ` |
149
152
| textDelegate | ` TextDelegate ` | 选择器的文本代理构建,用于自定义文本 | ` DefaultTextDelegate() ` |
153
+ | customItemBuilder | ` WidgetBuilder ` | 自定义item的构造方法 | ` null ` |
154
+ | customItemPosition | ` CustomItemPosition ` | 允许用户在选择器中添加一个自定义item,并指定位置。 | ` CustomItemPosition.none ` |
150
155
| routeCurve | ` Curve ` | 选择构造路由动画的曲线 | ` Curves.easeIn ` |
151
156
| routeDuration | ` Duration ` | 选择构造路由动画的时间 | ` const Duration(milliseconds: 500) ` |
152
157
@@ -166,49 +171,7 @@ AssetPicker.pickAsset(context).then((List<AssetEntity> assets) {
166
171
167
172
### 完整参数的使用方法
168
173
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 查看。
212
175
213
176
### 注册资源变化回调
214
177
``` dart
@@ -218,7 +181,95 @@ AssetPicker.registerObserve(); // 注册回调
218
181
AssetPicker.unregisterObserve(); // 取消注册回调
219
182
```
220
183
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
+ ## 常见问题 ❔
222
273
223
274
### 从` File ` 或` Uint8List ` 创建` AssetEntity ` 的方法
224
275
0 commit comments