@@ -414,29 +414,30 @@ abstract class AssetPickerBuilderDelegate<Asset, Path> {
414
414
);
415
415
}
416
416
417
+ /// Indicator when no assets were found from the current path.
418
+ /// 当前目录下无资源的显示
419
+ Widget emptyIndicator (BuildContext context) {
420
+ return ScaleText (
421
+ textDelegate.emptyList,
422
+ maxScaleFactor: 1.5 ,
423
+ semanticsLabel: semanticsTextDelegate.emptyList,
424
+ );
425
+ }
426
+
417
427
/// Loading indicator.
418
428
/// 加载指示器
419
429
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 ScaleText (
429
- textDelegate.emptyList,
430
- maxScaleFactor: 1.5 ,
431
- semanticsLabel: semanticsTextDelegate.emptyList,
432
- );
433
- }
434
- return w! ;
435
- },
436
- child: PlatformProgressIndicator (
437
- color: theme.iconTheme.color,
438
- size: context.mediaQuery.size.width / gridCount / 3 ,
439
- ),
430
+ return Selector <AssetPickerProvider <Asset , Path >, bool >(
431
+ selector: (_, AssetPickerProvider <Asset , Path > p) => p.isAssetsEmpty,
432
+ builder: (BuildContext context, bool isAssetsEmpty, Widget ? w) {
433
+ if (loadingIndicatorBuilder != null ) {
434
+ return loadingIndicatorBuilder !(context, isAssetsEmpty);
435
+ }
436
+ return Center (child: isAssetsEmpty ? emptyIndicator (context) : w);
437
+ },
438
+ child: PlatformProgressIndicator (
439
+ color: theme.iconTheme.color,
440
+ size: context.mediaQuery.size.width / gridCount / 3 ,
440
441
),
441
442
);
442
443
}
@@ -1039,8 +1040,7 @@ class DefaultAssetPickerBuilderDelegate
1039
1040
specialItem = null ;
1040
1041
}
1041
1042
if (totalCount == 0 && specialItem == null ) {
1042
- return loadingIndicatorBuilder? .call (context, true ) ??
1043
- Center (child: emptyIndicator (context));
1043
+ return loadingIndicator (context);
1044
1044
}
1045
1045
// Then we use the [totalCount] to calculate placeholders we need.
1046
1046
final int placeholderCount;
@@ -1525,32 +1525,6 @@ class DefaultAssetPickerBuilderDelegate
1525
1525
);
1526
1526
}
1527
1527
1528
- Widget emptyIndicator (BuildContext context) {
1529
- return ScaleText (
1530
- textDelegate.emptyList,
1531
- maxScaleFactor: 1.5 ,
1532
- semanticsLabel: semanticsTextDelegate.emptyList,
1533
- );
1534
- }
1535
-
1536
- @override
1537
- Widget loadingIndicator (BuildContext context) {
1538
- return Center (
1539
- child: Selector <DefaultAssetPickerProvider , bool >(
1540
- selector: (_, DefaultAssetPickerProvider p) => p.isAssetsEmpty,
1541
- builder: (BuildContext context, bool isAssetsEmpty, __) {
1542
- if (isAssetsEmpty) {
1543
- return emptyIndicator (context);
1544
- }
1545
- return PlatformProgressIndicator (
1546
- color: theme.iconTheme.color,
1547
- size: context.mediaQuery.size.width / gridCount / 3 ,
1548
- );
1549
- },
1550
- ),
1551
- );
1552
- }
1553
-
1554
1528
/// While the picker is switching path, this will displayed.
1555
1529
/// If the user tapped on it, it'll collapse the list widget.
1556
1530
///
0 commit comments