Skip to content

Commit a50a9e1

Browse files
committed
🐛 Fix path thumb data's display issue
1 parent 0778278 commit a50a9e1

File tree

2 files changed

+19
-9
lines changed

2 files changed

+19
-9
lines changed

lib/src/delegates/asset_picker_builder_delegate.dart

Lines changed: 8 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -906,16 +906,17 @@ class DefaultAssetPickerBuilderDelegate
906906
),
907907
),
908908
),
909-
child: Selector<DefaultAssetPickerProvider,
910-
Map<AssetPathEntity, Uint8List?>>(
911-
selector: (_, DefaultAssetPickerProvider p) => p.pathEntityList,
912-
builder: (_, Map<AssetPathEntity, Uint8List?> pathEntityList, __) {
909+
child: Selector<DefaultAssetPickerProvider, int>(
910+
selector: (_, DefaultAssetPickerProvider p) => p.validPathThumbCount,
911+
builder: (BuildContext c, int count, __) {
912+
final Map<AssetPathEntity, Uint8List?> list =
913+
c.watch<DefaultAssetPickerProvider>().pathEntityList;
913914
return ListView.separated(
914915
padding: const EdgeInsets.only(top: 1.0),
915-
itemCount: pathEntityList.length,
916+
itemCount: list.length,
916917
itemBuilder: (_, int index) => pathEntityWidget(
917-
context: context,
918-
list: pathEntityList,
918+
context: c,
919+
list: list,
919920
index: index,
920921
isAudio: isAudio,
921922
),

lib/src/provider/asset_picker_provider.dart

Lines changed: 11 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -15,8 +15,6 @@ import '../constants/constants.dart';
1515
/// By extending it you can customize how you can get all assets or paths,
1616
/// how to fetch the next page of assets, how to get the thumb data of a path.
1717
abstract class AssetPickerProvider<A, P> extends ChangeNotifier {
18-
/// Call [getAssetList] with route duration when constructing.
19-
/// 构造时根据路由时长延时获取资源
2018
AssetPickerProvider({
2119
this.maxAssets = 9,
2220
this.pageSize = 320,
@@ -129,6 +127,15 @@ abstract class AssetPickerProvider<A, P> extends ChangeNotifier {
129127

130128
Map<P, Uint8List?> get pathEntityList => _pathEntityList;
131129

130+
/// How many path has a valid thumb data.
131+
/// 当前有多少目录已经正常载入了缩略图
132+
///
133+
/// This getter provides a "Should Rebuild" condition judgement to [Selector]
134+
/// with the path entities widget.
135+
/// 它为目录部件展示部分的 [Selector] 提供了是否重建的条件。
136+
int get validPathThumbCount =>
137+
_pathEntityList.values.where((Uint8List? d) => d != null).length;
138+
132139
/// The path which is currently using.
133140
/// 正在查看的资源路径
134141
P? _currentPathEntity;
@@ -216,6 +223,8 @@ abstract class AssetPickerProvider<A, P> extends ChangeNotifier {
216223

217224
class DefaultAssetPickerProvider
218225
extends AssetPickerProvider<AssetEntity, AssetPathEntity> {
226+
/// Call [getAssetList] with route duration when constructing.
227+
/// 构造时根据路由时长延时获取资源
219228
DefaultAssetPickerProvider({
220229
List<AssetEntity>? selectedAssets,
221230
this.requestType = RequestType.image,

0 commit comments

Comments
 (0)