assetsGridItemCount method
The function which return items count for the assets' grid. 为资源列表提供内容数量计算的方法
Implementation
@override
int assetsGridItemCount(
BuildContext context,
List<AssetEntity> currentAssets,
) {
final AssetPathEntity? currentPathEntity =
context.select<DefaultAssetPickerProvider, AssetPathEntity?>(
(DefaultAssetPickerProvider p) => p.currentPathEntity,
);
if (currentPathEntity == null &&
specialItemPosition != SpecialItemPosition.none) {
return 1;
}
/// Return actual length if current path is all.
/// 如果当前目录是全部内容,则返回实际的内容数量。
final int _length = currentAssets.length;
if (!currentPathEntity!.isAll) {
return _length;
}
switch (specialItemPosition) {
case SpecialItemPosition.none:
return _length;
case SpecialItemPosition.prepend:
case SpecialItemPosition.append:
return _length + 1;
}
}