From 6888c8f1527f2bcaed4c04a5cf8d90dcca849526 Mon Sep 17 00:00:00 2001 From: ggurdin <46800240+ggurdin@users.noreply.github.com> Date: Thu, 3 Apr 2025 16:53:16 -0400 Subject: [PATCH] fix: dispose text painter to prevent memory leak (#2352) --- lib/pangea/toolbar/widgets/message_token_text.dart | 4 +++- 1 file changed, 3 insertions(+), 1 deletion(-) diff --git a/lib/pangea/toolbar/widgets/message_token_text.dart b/lib/pangea/toolbar/widgets/message_token_text.dart index ba35d7008..79b9a718d 100644 --- a/lib/pangea/toolbar/widgets/message_token_text.dart +++ b/lib/pangea/toolbar/widgets/message_token_text.dart @@ -188,7 +188,9 @@ class MessageTextWidget extends StatelessWidget { maxLines: 1, textDirection: TextDirection.ltr, )..layout(); - return textPainter.width; + final width = textPainter.width; + textPainter.dispose(); + return width; } Color backgroundColor(BuildContext context, TokenPosition tokenPosition) {