From 139744f884263ea03a9275feea5b7357ba364f20 Mon Sep 17 00:00:00 2001 From: sajee_techi Date: Tue, 13 Jan 2026 12:05:35 +0530 Subject: [PATCH] fix: defer state updates in receive screen dispose to avoid widget tree lock Wraps clearTipping(), updateMessage(), and updateListenerAmount() calls in addPostFrameCallback during dispose() to prevent "setState() or markNeedsBuild() called when widget tree was locked" error. These methods trigger notifyListeners() which cannot be called during the dispose phase. Deferring them until after the current frame ensures the widget tree is unlocked before state updates occur. --- lib/screens/wallet/receive.dart | 7 +++++++ 1 file changed, 7 insertions(+) diff --git a/lib/screens/wallet/receive.dart b/lib/screens/wallet/receive.dart index 00e6c080..fba2d4d4 100644 --- a/lib/screens/wallet/receive.dart +++ b/lib/screens/wallet/receive.dart @@ -80,6 +80,13 @@ class ReceiveScreenState extends State { widget.logic.clearInputControllers(); widget.profilesLogic.clearSearch(notify: false); + // Defer state updates until after the current frame to avoid widget tree lock + WidgetsBinding.instance.addPostFrameCallback((_) { + widget.logic.clearTipping(); + widget.logic.updateMessage(); + widget.logic.updateListenerAmount(); + }); + super.dispose(); }