From ae518e736fbff130807a657f1fc42f68e2dd2a8b Mon Sep 17 00:00:00 2001 From: qiangjindong Date: Wed, 9 Oct 2024 14:04:19 +0800 Subject: [PATCH] fix: too much memory to display the gif --- lib/src/photo_view_wrappers.dart | 9 +++++++++ 1 file changed, 9 insertions(+) diff --git a/lib/src/photo_view_wrappers.dart b/lib/src/photo_view_wrappers.dart index 7c1cb39..4cfbbc9 100644 --- a/lib/src/photo_view_wrappers.dart +++ b/lib/src/photo_view_wrappers.dart @@ -114,6 +114,12 @@ class _ImageWrapperState extends State { } void handleImageFrame(ImageInfo info, bool synchronousCall) { + if (_imageSize != null && _imageStream == null) { + _stopImageStream(); + _imageStream = null; + return; + } + final setupCB = () { _imageSize = Size( info.image.width.toDouble(), @@ -125,6 +131,9 @@ class _ImageWrapperState extends State { _loadingProgress = null; _lastException = null; _lastStack = null; + + _stopImageStream(); + _imageStream = null; }; synchronousCall ? setupCB() : setState(setupCB); }