screenshot icon indicating copy to clipboard operation
screenshot copied to clipboard

Memory not releasing while converting StatefulWidget with 4 high quality Image.memory used inside

Open OIBEK-SHOKIROV opened this issue 2 years ago • 2 comments

When I try to get screenshoot of StatefulWidget with 4 high quality Image.memory used inside, StatefulWidgets dispose method not working and it is not clearing Images from memory. Any fix?

OIBEK-SHOKIROV avatar Jul 25 '22 12:07 OIBEK-SHOKIROV

--- a/lib/screenshot.dart
+++ b/lib/screenshot.dart
@@ -246,7 +246,10 @@ class ScreenshotController {
       ///

     } while (isDirty && retryCounter >= 0);
-
+    rootElement.visitChildren((Element element) {
+      rootElement.deactivateChild(element);
+    });
+    buildOwner.finalizeTree();
     return image; // Adapted to directly return the image and not the Uint8List
   }
 }

Lan-tb avatar Aug 17 '22 14:08 Lan-tb

Same problem. Any fork available with this fix?

rignaneseleo avatar Dec 21 '22 17:12 rignaneseleo