From 19085446986e6edbd642473e6c5bdf3e2198d4f2 Mon Sep 17 00:00:00 2001 From: hailin Date: Sun, 28 Dec 2025 06:57:37 -0800 Subject: [PATCH] =?UTF-8?q?fix(mobile-app):=20=E4=BF=AE=E5=A4=8D=20Profile?= =?UTF-8?q?Page=20=E5=9C=A8=20initState=20=E4=B8=AD=E4=BF=AE=E6=94=B9=20pr?= =?UTF-8?q?ovider=20=E5=AF=BC=E8=87=B4=E7=9A=84=E9=94=99=E8=AF=AF?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit 将 _loadUnreadNotificationCount() 调用包装在 addPostFrameCallback 中, 延迟到 widget tree 构建完成后执行,避免 Riverpod 报错: "Tried to modify a provider while the widget tree was building" 🤖 Generated with [Claude Code](https://claude.com/claude-code) Co-Authored-By: Claude Opus 4.5 --- .../features/profile/presentation/pages/profile_page.dart | 6 ++++-- 1 file changed, 4 insertions(+), 2 deletions(-) diff --git a/frontend/mobile-app/lib/features/profile/presentation/pages/profile_page.dart b/frontend/mobile-app/lib/features/profile/presentation/pages/profile_page.dart index b90207eb..7ed8770f 100644 --- a/frontend/mobile-app/lib/features/profile/presentation/pages/profile_page.dart +++ b/frontend/mobile-app/lib/features/profile/presentation/pages/profile_page.dart @@ -201,8 +201,10 @@ class _ProfilePageState extends ConsumerState { _checkAndStartWalletPolling(); }); _loadAppInfo(); - // 通知数量(轻量级请求) - _loadUnreadNotificationCount(); + // 通知数量(轻量级请求)- 延迟到下一帧执行,避免在 build 期间修改 provider + WidgetsBinding.instance.addPostFrameCallback((_) { + _loadUnreadNotificationCount(); + }); // 启动定时刷新(可见区域的数据) _startAutoRefreshTimer(); }