diff --git a/mobile/lib/presentation/widgets/images/image_provider.dart b/mobile/lib/presentation/widgets/images/image_provider.dart index bdedd29d4..19701d7c7 100644 --- a/mobile/lib/presentation/widgets/images/image_provider.dart +++ b/mobile/lib/presentation/widgets/images/image_provider.dart @@ -98,6 +98,9 @@ mixin CancellableImageProviderMixin on CancellableImageProvide isFinished = isFinal; return codec; } catch (e) { + if (isCancelled) { + return null; + } if (isFinal) { isFinished = true; PaintingBinding.instance.imageCache.evict(this); @@ -111,16 +114,20 @@ mixin CancellableImageProviderMixin on CancellableImageProvide Stream initialImageStream() async* { final cachedOperation = this.cachedOperation; - if (cachedOperation == null) { + if (isCancelled || cachedOperation == null) { return; } try { final cachedImage = await cachedOperation.valueOrCancellation(); - if (cachedImage != null && !isCancelled) { - yield cachedImage; + if (isCancelled || cachedImage == null) { + return; } + yield cachedImage; } catch (e, stack) { + if (isCancelled) { + return; + } _log.severe('Error loading initial image', e, stack); } finally { this.cachedOperation = null;