From e58f2a1f35e4b41124fe6ae953728923ca067e9c Mon Sep 17 00:00:00 2001 From: Salvatore Giordano Date: Fri, 10 Apr 2020 17:13:16 +0200 Subject: [PATCH] fix video loading and error --- lib/src/message_widget.dart | 47 ++++++++++++++++++++++--------------- 1 file changed, 28 insertions(+), 19 deletions(-) diff --git a/lib/src/message_widget.dart b/lib/src/message_widget.dart index d2c84efb..cbdf131c 100644 --- a/lib/src/message_widget.dart +++ b/lib/src/message_widget.dart @@ -1038,8 +1038,12 @@ class _MessageWidgetState extends State future: videoController.initialize(), builder: (_, snapshot) { if (snapshot.connectionState != ConnectionState.done) { - return Center( - child: CircularProgressIndicator(), + return Container( + height: 100, + width: 100, + child: Center( + child: CircularProgressIndicator(), + ), ); } ChewieController chewieController; @@ -1052,26 +1056,31 @@ class _MessageWidgetState extends State autoInitialize: false, aspectRatio: videoController.value.aspectRatio, errorBuilder: (_, e) { - return Stack( - children: [ - Container( - decoration: BoxDecoration( - image: DecorationImage( - fit: BoxFit.cover, - image: CachedNetworkImageProvider( - attachment.thumbUrl, + if (attachment.thumbUrl != null) { + return Stack( + children: [ + Container( + decoration: BoxDecoration( + image: DecorationImage( + fit: BoxFit.cover, + image: CachedNetworkImageProvider( + attachment.thumbUrl, + ), ), ), ), - ), - Material( - color: Colors.transparent, - child: InkWell( - onTap: () => _launchURL(attachment.titleLink), - ), - ), - ], - ); + if (attachment.titleLink != null) + Material( + color: Colors.transparent, + child: InkWell( + onTap: () => _launchURL(attachment.titleLink), + ), + ), + ], + ); + } + + return _buildErrorImage(attachment); }); _chuwieControllers[attachment.assetUrl] = chewieController; }