|
@@ -3,6 +3,9 @@ library photo;
|
3
|
3
|
import 'dart:async';
|
4
|
4
|
|
5
|
5
|
import 'package:flutter/material.dart';
|
|
6
|
+
|
|
7
|
+import 'package:photo_manager/photo_manager.dart';
|
|
8
|
+
|
6
|
9
|
import 'package:photo/src/delegate/badge_delegate.dart';
|
7
|
10
|
import 'package:photo/src/delegate/checkbox_builder_delegate.dart';
|
8
|
11
|
import 'package:photo/src/delegate/loading_delegate.dart';
|
|
@@ -11,8 +14,6 @@ import 'package:photo/src/entity/options.dart';
|
11
|
14
|
import 'package:photo/src/provider/i18n_provider.dart';
|
12
|
15
|
import 'package:photo/src/ui/dialog/not_permission_dialog.dart';
|
13
|
16
|
import 'package:photo/src/ui/photo_app.dart';
|
14
|
|
-import 'package:photo_manager/photo_manager.dart';
|
15
|
|
-
|
16
|
17
|
export 'package:photo/src/delegate/checkbox_builder_delegate.dart';
|
17
|
18
|
export 'package:photo/src/delegate/loading_delegate.dart';
|
18
|
19
|
export 'package:photo/src/delegate/sort_delegate.dart';
|
|
@@ -42,7 +43,9 @@ class PhotoPicker {
|
42
|
43
|
/// 当用户确定时,返回一个图片[AssetEntity]列表
|
43
|
44
|
///
|
44
|
45
|
/// 当用户取消时返回一个空数组
|
45
|
|
- ///
|
|
46
|
+ ///
|
|
47
|
+ /// [photoList] 一旦设置 则 [pickType]参数无效
|
|
48
|
+ ///
|
46
|
49
|
/// 关于参数可以查看readme文档介绍
|
47
|
50
|
///
|
48
|
51
|
/// if user not grand permission, then return null and show a dialog to help user open setting.
|
|
@@ -53,6 +56,8 @@ class PhotoPicker {
|
53
|
56
|
/// when user sure , return a [AssetEntity] of [List]
|
54
|
57
|
///
|
55
|
58
|
/// when user cancel selected,result is empty list
|
|
59
|
+ ///
|
|
60
|
+ /// when [photoList] is not null , [pickType] invalid
|
56
|
61
|
///
|
57
|
62
|
/// params see readme.md
|
58
|
63
|
static Future<List<AssetEntity>> pickAsset({
|
|
@@ -72,6 +77,7 @@ class PhotoPicker {
|
72
|
77
|
LoadingDelegate loadingDelegate,
|
73
|
78
|
PickType pickType = PickType.all,
|
74
|
79
|
BadgeDelegate badgeDelegate = const DefaultBadgeDelegate(),
|
|
80
|
+ List<AssetPathEntity> photoList,
|
75
|
81
|
}) {
|
76
|
82
|
assert(provider != null, "provider must be not null");
|
77
|
83
|
assert(context != null, "context must be not null");
|
|
@@ -108,6 +114,7 @@ class PhotoPicker {
|
108
|
114
|
context,
|
109
|
115
|
options,
|
110
|
116
|
provider,
|
|
117
|
+ photoList,
|
111
|
118
|
);
|
112
|
119
|
}
|
113
|
120
|
|
|
@@ -115,6 +122,7 @@ class PhotoPicker {
|
115
|
122
|
BuildContext context,
|
116
|
123
|
Options options,
|
117
|
124
|
I18nProvider provider,
|
|
125
|
+ List<AssetPathEntity> photoList,
|
118
|
126
|
) async {
|
119
|
127
|
var requestPermission = await PhotoManager.requestPermission();
|
120
|
128
|
if (requestPermission != true) {
|
|
@@ -130,16 +138,21 @@ class PhotoPicker {
|
130
|
138
|
return null;
|
131
|
139
|
}
|
132
|
140
|
|
133
|
|
- return _openGalleryContentPage(context, options, provider);
|
|
141
|
+ return _openGalleryContentPage(context, options, provider, photoList);
|
134
|
142
|
}
|
135
|
143
|
|
136
|
144
|
Future<List<AssetEntity>> _openGalleryContentPage(
|
137
|
|
- BuildContext context, Options options, I18nProvider provider) async {
|
|
145
|
+ BuildContext context,
|
|
146
|
+ Options options,
|
|
147
|
+ I18nProvider provider,
|
|
148
|
+ List<AssetPathEntity> photoList,
|
|
149
|
+ ) async {
|
138
|
150
|
return Navigator.of(context).push(
|
139
|
151
|
MaterialPageRoute(
|
140
|
152
|
builder: (ctx) => PhotoApp(
|
141
|
153
|
options: options,
|
142
|
154
|
provider: provider,
|
|
155
|
+ photoList: photoList,
|
143
|
156
|
),
|
144
|
157
|
),
|
145
|
158
|
);
|