getImageWidget function

Widget getImageWidget(
  1. String filePath, [
  2. bool isAlert = false
])

Implementation

Widget getImageWidget(String filePath, [bool isAlert = false]) {
  if (filePath.startsWith('http')) {
    return Image.network(
      filePath,
      scale: 4,
    );
  }
  else if (filePath.endsWith('.mp4') || filePath.endsWith('.avi')) {
    if(isAlert){

      return VideoPlayerWidget(videoPath: filePath);

    }else{
    return FutureBuilder<t.Uint8List?>(
      future: _getFirstFrameThumbnail(filePath),
      builder: (context, snapshot) {
        if (snapshot.connectionState == ConnectionState.done && snapshot.hasData) {
          return Image.memory(
            snapshot.data!,
            fit: BoxFit.cover,
          );
        } else {
          return const Icon(
            Icons.videocam,
            size: 50,
            color: Colors.black,
          );
        }
      },
    );
    }
  }
  else {
    return Image.file(
      File(filePath),
      scale: 4,
    );
  }
}