fix video loading and error

This commit is contained in:
Salvatore Giordano
2020-04-10 17:16:23 +02:00
parent 18d76f505c
commit fefcc50280
+28 -19
View File
@@ -952,8 +952,12 @@ class _MessageWidgetState extends State<MessageWidget>
future: videoController.initialize(), future: videoController.initialize(),
builder: (_, snapshot) { builder: (_, snapshot) {
if (snapshot.connectionState != ConnectionState.done) { if (snapshot.connectionState != ConnectionState.done) {
return Center( return Container(
child: CircularProgressIndicator(), height: 100,
width: 100,
child: Center(
child: CircularProgressIndicator(),
),
); );
} }
ChewieController chewieController; ChewieController chewieController;
@@ -966,26 +970,31 @@ class _MessageWidgetState extends State<MessageWidget>
autoInitialize: false, autoInitialize: false,
aspectRatio: videoController.value.aspectRatio, aspectRatio: videoController.value.aspectRatio,
errorBuilder: (_, e) { errorBuilder: (_, e) {
return Stack( if (attachment.thumbUrl != null) {
children: <Widget>[ return Stack(
Container( children: <Widget>[
decoration: BoxDecoration( Container(
image: DecorationImage( decoration: BoxDecoration(
fit: BoxFit.cover, image: DecorationImage(
image: CachedNetworkImageProvider( fit: BoxFit.cover,
attachment.thumbUrl, image: CachedNetworkImageProvider(
attachment.thumbUrl,
),
), ),
), ),
), ),
), if (attachment.titleLink != null)
Material( Material(
color: Colors.transparent, color: Colors.transparent,
child: InkWell( child: InkWell(
onTap: () => _launchURL(attachment.titleLink), onTap: () => _launchURL(attachment.titleLink),
), ),
), ),
], ],
); );
}
return _buildErrorImage(attachment);
}); });
_chuwieControllers[attachment.assetUrl] = chewieController; _chuwieControllers[attachment.assetUrl] = chewieController;
} }