Skip to content

Commit

Permalink
weakref fix
Browse files Browse the repository at this point in the history
  • Loading branch information
marandaneto committed Nov 28, 2024
1 parent 3d3f9c1 commit 4cc4ef5
Showing 1 changed file with 5 additions and 3 deletions.
8 changes: 5 additions & 3 deletions lib/src/replay/screenshot/screenshot_capturer.dart
Original file line number Diff line number Diff line change
Expand Up @@ -27,7 +27,8 @@ class ViewTreeSnapshotStatus {
class ScreenshotCapturer {
final PostHogConfig _config;
final ImageMaskPainter _imageMaskPainter = ImageMaskPainter();
final Map<RenderObject, ViewTreeSnapshotStatus> views = {};
// Expando is the equivalent of weakref
final _views = Expando();

ScreenshotCapturer(this._config);

Expand All @@ -47,7 +48,7 @@ class ScreenshotCapturer {
ViewTreeSnapshotStatus statusView) {
if (shouldSendMetaEvent) {
statusView.sentMetaEvent = true;
views[renderObject] = statusView;
_views[renderObject] = statusView;
}
}

Expand All @@ -62,7 +63,8 @@ class ScreenshotCapturer {
return null;
}

final statusView = views[renderObject] ?? ViewTreeSnapshotStatus(false);
final statusView = (_views[renderObject] as ViewTreeSnapshotStatus?) ??
ViewTreeSnapshotStatus(false);

var shouldSendMetaEvent = false;
if (!statusView.sentMetaEvent) {
Expand Down

0 comments on commit 4cc4ef5

Please sign in to comment.