imageAndVideoItemBuilder method

  1. @override
Widget imageAndVideoItemBuilder(
  1. BuildContext context,
  2. int index,
  3. AssetEntity asset
)
override

The item builder for images and video type of asset. 图片和视频资源的部件构建

Implementation

@override
Widget imageAndVideoItemBuilder(
  BuildContext context,
  int index,
  AssetEntity asset,
) {
  final AssetEntityImageProvider imageProvider = AssetEntityImageProvider(
    asset,
    isOriginal: false,
    thumbnailSize: gridThumbnailSize,
  );
  SpecialImageType? type;
  if (imageProvider.imageFileType == ImageFileType.gif) {
    type = SpecialImageType.gif;
  } else if (imageProvider.imageFileType == ImageFileType.heic) {
    type = SpecialImageType.heic;
  }
  return Stack(
    children: <Widget>[
      Positioned.fill(
        child: RepaintBoundary(
          child: AssetEntityGridItemBuilder(
            image: imageProvider,
            failedItemBuilder: failedItemBuilder,
          ),
        ),
      ),
      if (type == SpecialImageType.gif) // 如果为GIF则显示标识
        gifIndicator(context, asset),
      if (asset.type == AssetType.video) // 如果为视频则显示标识
        videoIndicator(context, asset),
    ],
  );
}