diff --git a/lib/nft_rendering/gif_rendering_widget.dart b/lib/nft_rendering/gif_rendering_widget.dart index 21e6ec831..d1d3795ef 100644 --- a/lib/nft_rendering/gif_rendering_widget.dart +++ b/lib/nft_rendering/gif_rendering_widget.dart @@ -34,8 +34,10 @@ class _GifNFTRenderingWidgetState extends State { void initState() { super.initState(); if (widget.previewURL.isEmpty) { - setState(() { - _isLoading = false; + WidgetsBinding.instance.addPostFrameCallback((_) { + setState(() { + _isLoading = false; + }); }); } } @@ -81,15 +83,15 @@ class _GifNFTRenderingWidgetState extends State { void _onImageLoaded() { if (_isLoading) { - setState(() { - _isLoading = false; + WidgetsBinding.instance?.addPostFrameCallback((_) { + setState(() { + _isLoading = false; + }); }); widget.onLoaded?.call(); } } @override - Widget build(BuildContext context) => _isLoading - ? widget.loadingWidget ?? const Center(child: CircularProgressIndicator()) - : _buildGifWidget(); + Widget build(BuildContext context) => _buildGifWidget(); } diff --git a/lib/nft_rendering/video_player_widget.dart b/lib/nft_rendering/video_player_widget.dart index 3313938e7..4e2ad84ee 100644 --- a/lib/nft_rendering/video_player_widget.dart +++ b/lib/nft_rendering/video_player_widget.dart @@ -174,14 +174,12 @@ class _VideoNFTRenderingWidgetState return widget.noPreviewUrlWidget; // Show no preview URL widget } - if (_shouldUseThumbnail && thumbnailURL != null) { + if ((_shouldUseThumbnail || _isPlayingFailed) && thumbnailURL != null) { return _videoThumbnail(thumbnailURL); } if (_controller != null) { - if ((_isPlayingFailed || _shouldUseThumbnail) && thumbnailURL != null) { - return _videoThumbnail(thumbnailURL); - } else if (_isPreviewLoaded) { + if (_isPreviewLoaded) { return Stack( children: [ Center( diff --git a/lib/view/feralfile_artwork_preview_widget.dart b/lib/view/feralfile_artwork_preview_widget.dart index 268d36eb3..3aa3b75f0 100644 --- a/lib/view/feralfile_artwork_preview_widget.dart +++ b/lib/view/feralfile_artwork_preview_widget.dart @@ -69,70 +69,71 @@ class _FeralfileArtworkPreviewWidgetState return BlocProvider( create: (_) => RetryCubit(), child: BlocBuilder( - builder: (context, attempt) { - return BlocBuilder( - bloc: context.read(), - builder: (context, state) { - final medium = state.mediumMap[previewUrl]; - if (medium == null) { - return const SizedBox(); - } - switch (medium) { - case RenderingType.image: - return InteractiveViewer( - minScale: 1, - maxScale: 4, - child: Center( - child: ImageNFTRenderingWidget( - previewURL: previewUrl, - ), - ), - ); - case RenderingType.video: - return InteractiveViewer( - minScale: 1, - maxScale: 4, - child: Center( - child: VideoNFTRenderingWidget( - key: Key('video_nft_rendering_widget_$previewUrl'), - previewURL: previewUrl, - thumbnailURL: thumbnailUrl, - ), - ), - ); - case RenderingType.gif: - return InteractiveViewer( - minScale: 1, - maxScale: 4, - child: Center( - child: GifNFTRenderingWidget( - previewURL: previewUrl, - ), + builder: (context, attempt) => + BlocBuilder( + bloc: context.read(), + builder: (context, state) { + final medium = state.mediumMap[previewUrl]; + if (medium == null) { + return const SizedBox(); + } + switch (medium) { + case RenderingType.image: + return InteractiveViewer( + minScale: 1, + maxScale: 4, + child: Center( + child: ImageNFTRenderingWidget( + previewURL: previewUrl, ), - ); - case RenderingType.svg: - return InteractiveViewer( - minScale: 1, - maxScale: 4, - child: Center( - child: SVGNFTRenderingWidget(previewURL: previewUrl)), - ); - case RenderingType.pdf: - return Center( - child: PDFNFTRenderingWidget( + ), + ); + case RenderingType.video: + return InteractiveViewer( + minScale: 1, + maxScale: 4, + child: Center( + child: VideoNFTRenderingWidget( + key: Key('video_nft_rendering_widget_$previewUrl'), previewURL: previewUrl, + thumbnailURL: thumbnailUrl, + isMute: widget.payload.isMute, ), - ); - default: - return Center( - child: WebviewNFTRenderingWidget( + ), + ); + case RenderingType.gif: + return InteractiveViewer( + minScale: 1, + maxScale: 4, + child: Center( + child: GifNFTRenderingWidget( previewURL: previewUrl, ), - ); - } - }, - ); - }, + ), + ); + case RenderingType.svg: + return InteractiveViewer( + minScale: 1, + maxScale: 4, + child: Center( + child: SVGNFTRenderingWidget(previewURL: previewUrl)), + ); + case RenderingType.pdf: + return Center( + child: PDFNFTRenderingWidget( + previewURL: previewUrl, + ), + ); + default: + return Center( + child: WebviewNFTRenderingWidget( + previewURL: previewUrl, + isMute: widget.payload.isMute, + ), + ); + } + }, + ), ), ); }