diff --git a/lib/pangea/widgets/chat/message_toolbar.dart b/lib/pangea/widgets/chat/message_toolbar.dart index 8d2d66b7d..e10d637e0 100644 --- a/lib/pangea/widgets/chat/message_toolbar.dart +++ b/lib/pangea/widgets/chat/message_toolbar.dart @@ -194,6 +194,8 @@ class MessageToolbarState extends State { late StreamSubscription toolbarModeStream; void updateMode(MessageMode newMode) { + //Early exit from the function if the widget has been unmounted to prevent updates on an inactive widget. + if (!mounted) return; if (updatingMode) return; debugPrint("updating toolbar mode"); final bool subscribed = @@ -347,6 +349,7 @@ class MessageToolbarState extends State { Timer? timer; selectionStream = widget.textSelection.selectionStream.stream.listen((value) { + //talk about this timer?.cancel(); timer = Timer(const Duration(milliseconds: 500), () { if (value != null && value.isNotEmpty) {