@@ -495,21 +495,35 @@ class DefaultAssetPickerProvider
495
495
/// Get assets list from current path entity.
496
496
/// 从当前已选路径获取资源列表
497
497
Future <void > getAssetsFromCurrentPath () async {
498
- if (_currentPath == null || _paths.isEmpty) {
498
+ if (_paths.isEmpty && _currentPath != null ) {
499
+ throw StateError ('The current path is not synced with the empty paths.' );
500
+ }
501
+ if (_paths.isNotEmpty && _currentPath == null ) {
502
+ throw StateError ('The empty path is not synced with the current paths.' );
503
+ }
504
+ if (_paths.isEmpty || _currentPath == null ) {
499
505
isAssetsEmpty = true ;
500
506
return ;
501
507
}
502
508
final PathWrapper <AssetPathEntity > wrapper = _currentPath! ;
503
- final int assetCount =
504
- wrapper.assetCount ?? await wrapper.path.assetCountAsync;
505
- // If the picker was disposed (#492), stop fetching the assets
506
- if (! mounted) {
507
- return ;
508
- }
509
- totalAssetsCount = assetCount;
510
- isAssetsEmpty = assetCount == 0 ;
511
509
if (wrapper.assetCount == null ) {
512
- currentPath = _currentPath! .copyWith (assetCount: assetCount);
510
+ final int assetCount = await wrapper.path.assetCountAsync;
511
+ // If the picker was disposed (#492), stop fetching the assets.
512
+ if (! mounted) {
513
+ return ;
514
+ }
515
+ if (_paths.isNotEmpty &&
516
+ _currentPath != null &&
517
+ _currentPath! .assetCount == null ) {
518
+ _totalAssetsCount = assetCount;
519
+ _isAssetsEmpty = assetCount == 0 ;
520
+ _currentPath = wrapper.copyWith (assetCount: assetCount);
521
+ notifyListeners ();
522
+ } else if (_currentPath? .assetCount case final int count) {
523
+ _totalAssetsCount = count;
524
+ _isAssetsEmpty = count == 0 ;
525
+ notifyListeners ();
526
+ }
513
527
}
514
528
await getAssetsFromPath (0 , currentPath! .path);
515
529
}
0 commit comments