@@ -24,10 +24,11 @@ class AssetPicker extends StatelessWidget {
24
24
AssetPicker ({
25
25
Key key,
26
26
@required this .provider,
27
- this .pickerTheme,
28
27
int gridCount = 4 ,
29
28
Color themeColor,
30
29
AssetsPickerTextDelegate textDelegate,
30
+ this .pickerTheme,
31
+ this .previewThumbSize,
31
32
this .specialPickerType,
32
33
this .customItemPosition = CustomItemPosition .none,
33
34
this .customItemBuilder,
@@ -61,11 +62,25 @@ class AssetPicker extends StatelessWidget {
61
62
/// Theme for the picker.
62
63
/// 选择器的主题
63
64
///
64
- /// Usually the WeChat uses the dark version (dark background color) for the picker.
65
- /// However, some developer wants a light theme version for some reasons.
65
+ /// Usually the WeChat uses the dark version (dark background color)
66
+ /// for the picker. However, some others want a light or a custom version.
67
+ ///
66
68
/// 通常情况下微信选择器使用的是暗色(暗色背景)的主题,但某些情况下开发者需要亮色或自定义主题。
67
69
final ThemeData pickerTheme;
68
70
71
+ /// Thumb size for the preview of images in the viewer.
72
+ /// 预览时图片的缩略图大小
73
+ ///
74
+ /// This only works on images since other types does not have request
75
+ /// for thumb data. The speed of preview can be raised by reducing it.
76
+ ///
77
+ /// 该参数仅生效于图片类型的资源,因为其他资源不需要请求缩略图数据。
78
+ /// 预览图片的速度可以通过适当降低它的数值来提升。
79
+ ///
80
+ /// Default is `null` , which will request the origin data.
81
+ /// 默认为空,即读取原图。
82
+ final List <int > previewThumbSize;
83
+
69
84
/// The current special picker type for the picker.
70
85
/// 当前特殊选择类型
71
86
///
@@ -93,6 +108,7 @@ class AssetPicker extends StatelessWidget {
93
108
int pageSize = 320 ,
94
109
int pathThumbSize = 200 ,
95
110
int gridCount = 4 ,
111
+ List <int > previewThumbSize,
96
112
RequestType requestType,
97
113
SpecialPickerType specialPickerType,
98
114
List <AssetEntity > selectedAssets,
@@ -159,6 +175,7 @@ class AssetPicker extends StatelessWidget {
159
175
textDelegate: textDelegate,
160
176
themeColor: themeColor,
161
177
pickerTheme: pickerTheme,
178
+ previewThumbSize: previewThumbSize,
162
179
specialPickerType: specialPickerType,
163
180
customItemPosition: customItemPosition,
164
181
customItemBuilder: customItemBuilder,
@@ -383,6 +400,7 @@ class AssetPicker extends StatelessWidget {
383
400
/// The reason that the `thumbData` should be checked at here to see if it is
384
401
/// null is that even the image file is not exist, the `File` can still
385
402
/// returned as it exist, which will cause the thumb bytes return null.
403
+ ///
386
404
/// 此处需要检查缩略图为空的原因是:尽管文件可能已经被删除,但通过`File` 读取的文件对象
387
405
/// 仍然存在,使得返回的数据为空。
388
406
final Uint8List thumbData = pathEntityList[pathEntity];
@@ -587,6 +605,7 @@ class AssetPicker extends StatelessWidget {
587
605
/// 确认按钮
588
606
///
589
607
/// It'll pop with [AssetPickerProvider.selectedAssets] when there're any assets chosen.
608
+ ///
590
609
/// 当有资源已选时,点击按钮将把已选资源通过路由返回。
591
610
Widget confirmButton (BuildContext context) => Consumer <AssetPickerProvider >(
592
611
builder: (BuildContext _, AssetPickerProvider provider, Widget __) {
@@ -702,6 +721,7 @@ class AssetPicker extends StatelessWidget {
702
721
/// Videos often contains various of color in the cover,
703
722
/// so in order to keep the content visible in most cases,
704
723
/// the color of the indicator has been set to [Colors.white] .
724
+ ///
705
725
/// 视频封面通常包含各种颜色,为了保证内容在一般情况下可见,此处
706
726
/// 将指示器的图标和文字设置为 [Colors.white] 。
707
727
Widget videoIndicator (AssetEntity asset) {
@@ -769,6 +789,7 @@ class AssetPicker extends StatelessWidget {
769
789
currentIndex: index,
770
790
assets: provider.currentAssets,
771
791
themeData: theme,
792
+ previewThumbSize: previewThumbSize,
772
793
specialPickerType:
773
794
asset.type == AssetType .video ? specialPickerType : null ,
774
795
);
@@ -1129,6 +1150,7 @@ class AssetPicker extends StatelessWidget {
1129
1150
context,
1130
1151
currentIndex: 0 ,
1131
1152
assets: provider.selectedAssets,
1153
+ previewThumbSize: previewThumbSize,
1132
1154
selectedAssets: provider.selectedAssets,
1133
1155
selectorProvider: provider,
1134
1156
themeData: theme,
0 commit comments