@@ -359,6 +359,16 @@ abstract class AssetPickerBuilderDelegate<Asset, Path> {
359
359
/// Android设备的选择器布局
360
360
Widget androidLayout (BuildContext context);
361
361
362
+ /// Loading indicator.
363
+ /// 加载指示器
364
+ ///
365
+ /// Subclasses need to implement this due to the generic type limitation, and
366
+ /// not all delegates use [AssetPickerProvider] .
367
+ ///
368
+ /// See also:
369
+ /// - [DefaultAssetPickerBuilderDelegate.loadingIndicator] as an example.
370
+ Widget loadingIndicator (BuildContext context);
371
+
362
372
/// GIF image type indicator.
363
373
/// GIF 类型图片指示
364
374
Widget gifIndicator (BuildContext context, Asset asset) {
@@ -414,29 +424,8 @@ abstract class AssetPickerBuilderDelegate<Asset, Path> {
414
424
);
415
425
}
416
426
417
- /// Loading indicator.
418
- /// 加载指示器
419
- Widget loadingIndicator (BuildContext context) {
420
- return Center (
421
- child: Selector <AssetPickerProvider <Asset , Path >, bool >(
422
- selector: (_, AssetPickerProvider <Asset , Path > p) => p.isAssetsEmpty,
423
- builder: (BuildContext c, bool isAssetsEmpty, Widget ? w) {
424
- if (loadingIndicatorBuilder != null ) {
425
- return loadingIndicatorBuilder !(c, isAssetsEmpty);
426
- }
427
- if (isAssetsEmpty) {
428
- return emptyIndicator (context);
429
- }
430
- return w! ;
431
- },
432
- child: PlatformProgressIndicator (
433
- color: theme.iconTheme.color,
434
- size: context.mediaQuery.size.width / gridCount / 3 ,
435
- ),
436
- ),
437
- );
438
- }
439
-
427
+ /// Indicator when no assets were found from the current path.
428
+ /// 当前目录下无资源的显示
440
429
Widget emptyIndicator (BuildContext context) {
441
430
return ScaleText (
442
431
textDelegate.emptyList,
@@ -1022,6 +1011,23 @@ class DefaultAssetPickerBuilderDelegate
1022
1011
);
1023
1012
}
1024
1013
1014
+ @override
1015
+ Widget loadingIndicator (BuildContext context) {
1016
+ return Selector <DefaultAssetPickerProvider , bool >(
1017
+ selector: (_, DefaultAssetPickerProvider p) => p.isAssetsEmpty,
1018
+ builder: (BuildContext context, bool isAssetsEmpty, Widget ? w) {
1019
+ if (loadingIndicatorBuilder != null ) {
1020
+ return loadingIndicatorBuilder !(context, isAssetsEmpty);
1021
+ }
1022
+ return Center (child: isAssetsEmpty ? emptyIndicator (context) : w);
1023
+ },
1024
+ child: PlatformProgressIndicator (
1025
+ color: theme.iconTheme.color,
1026
+ size: context.mediaQuery.size.width / gridCount / 3 ,
1027
+ ),
1028
+ );
1029
+ }
1030
+
1025
1031
@override
1026
1032
Widget assetsGridBuilder (BuildContext context) {
1027
1033
return Selector <DefaultAssetPickerProvider , PathWrapper <AssetPathEntity >?>(
@@ -1048,8 +1054,7 @@ class DefaultAssetPickerBuilderDelegate
1048
1054
specialItem = null ;
1049
1055
}
1050
1056
if (totalCount == 0 && specialItem == null ) {
1051
- return loadingIndicatorBuilder? .call (context, true ) ??
1052
- loadingIndicator (context);
1057
+ return loadingIndicator (context);
1053
1058
}
1054
1059
// Then we use the [totalCount] to calculate placeholders we need.
1055
1060
final int placeholderCount;
@@ -1536,24 +1541,6 @@ class DefaultAssetPickerBuilderDelegate
1536
1541
);
1537
1542
}
1538
1543
1539
- @override
1540
- Widget loadingIndicator (BuildContext context) {
1541
- return Center (
1542
- child: Selector <DefaultAssetPickerProvider , bool >(
1543
- selector: (_, DefaultAssetPickerProvider p) => p.isAssetsEmpty,
1544
- builder: (BuildContext context, bool isAssetsEmpty, __) {
1545
- if (isAssetsEmpty) {
1546
- return emptyIndicator (context);
1547
- }
1548
- return PlatformProgressIndicator (
1549
- color: theme.iconTheme.color,
1550
- size: context.mediaQuery.size.width / gridCount / 3 ,
1551
- );
1552
- },
1553
- ),
1554
- );
1555
- }
1556
-
1557
1544
/// While the picker is switching path, this will displayed.
1558
1545
/// If the user tapped on it, it'll collapse the list widget.
1559
1546
///
0 commit comments