diff --git a/lib/src/message_input.dart b/lib/src/message_input.dart index c9ed15bb..04161aef 100644 --- a/lib/src/message_input.dart +++ b/lib/src/message_input.dart @@ -1316,10 +1316,18 @@ class MessageInputState extends State { children: [ Positioned.fill( child: Container( - child: VideoThumbnail( - file: File( - attachment.file.path, - ), + child: FutureBuilder( + future: VideoCompress.getFileThumbnail(attachment.file.path), + builder: (context, snapshot) { + if (!snapshot.hasData) { + return Offstage(); + } + + return Image.file( + snapshot.data, + fit: BoxFit.cover, + ); + }, ), ), ), diff --git a/lib/src/video_thumbnail.dart b/lib/src/video_thumbnail.dart deleted file mode 100644 index c36ab327..00000000 --- a/lib/src/video_thumbnail.dart +++ /dev/null @@ -1,37 +0,0 @@ -import 'dart:io'; - -import 'package:flutter/material.dart'; -import 'package:video_player/video_player.dart'; - -class VideoThumbnail extends StatefulWidget { - final File file; - - const VideoThumbnail({ - Key key, - @required this.file, - }) : super(key: key); - - @override - _VideoThumbnailState createState() => _VideoThumbnailState(); -} - -class _VideoThumbnailState extends State { - VideoPlayerController _videoPlayerController; - @override - Widget build(BuildContext context) { - return VideoPlayer(_videoPlayerController); - } - - @override - void initState() { - _videoPlayerController = VideoPlayerController.file(widget.file) - ..initialize(); - super.initState(); - } - - @override - void dispose() { - _videoPlayerController.dispose(); - super.dispose(); - } -}