buildThumbnail method

Widget buildThumbnail(
  1. MediaItem item
)

Build the thumbnail for the history item.

Implementation

Widget buildThumbnail(MediaItem item) {
  return Stack(
    alignment: Alignment.bottomCenter,
    children: [
      ColoredBox(
        color: theme.unselectedWidgetColor.withOpacity(0.1),
        child: AspectRatio(
          aspectRatio: mediaSource.aspectRatio,
          child: FadeInImage(
            key: UniqueKey(),
            placeholder: MemoryImage(kTransparentImage),
            imageErrorBuilder: (_, __, ___) {
              if (item.extraUrl != null) {
                return FadeInImage(
                  placeholder: MemoryImage(kTransparentImage),
                  imageErrorBuilder: (_, __, ___) => const SizedBox.expand(),
                  image: mediaSource.getDisplayThumbnailFromMediaItem(
                    appModel: appModel,
                    item: item,
                    fallbackUrl: item.extraUrl,
                  ),
                  fit: BoxFit.fitWidth,
                );
              } else {
                return const SizedBox.expand();
              }
            },
            image: mediaSource.getDisplayThumbnailFromMediaItem(
              appModel: appModel,
              item: item,
            ),
            fit: BoxFit.fitWidth,
          ),
        ),
      ),
      Positioned(
        right: 4,
        bottom: 6,
        child: Container(
          height: 20,
          color: Colors.black.withOpacity(0.8),
          alignment: Alignment.center,
          child: Text(
            JidoujishoTimeFormat.getVideoDurationText(
                Duration(seconds: item.duration)),
            style: const TextStyle(
              fontSize: 12,
              color: Colors.white,
              fontWeight: FontWeight.w300,
            ),
          ),
        ),
      ),
      Positioned(
        child: Container(
          alignment: Alignment.bottomCenter,
          child: LinearProgressIndicator(
            value: (item.position / item.duration).isNaN ||
                    (item.position / item.duration) == double.infinity ||
                    (item.position == 0 && item.duration == 0)
                ? 0
                : ((item.position / item.duration) > 0.97)
                    ? 1
                    : (item.position / item.duration),
            backgroundColor: Colors.white.withOpacity(0.6),
            valueColor: const AlwaysStoppedAnimation<Color>(Colors.red),
            minHeight: 2,
          ),
        ),
      ),
    ],
  );
}