fix(mobile-app): 修复 ProfilePage 在 initState 中修改 provider 导致的错误

将 _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 <noreply@anthropic.com>
This commit is contained in:
hailin 2025-12-28 06:57:37 -08:00
parent b3142387f7
commit 1908544698
1 changed files with 4 additions and 2 deletions

View File

@ -201,8 +201,10 @@ class _ProfilePageState extends ConsumerState<ProfilePage> {
_checkAndStartWalletPolling(); _checkAndStartWalletPolling();
}); });
_loadAppInfo(); _loadAppInfo();
// // - build provider
_loadUnreadNotificationCount(); WidgetsBinding.instance.addPostFrameCallback((_) {
_loadUnreadNotificationCount();
});
// //
_startAutoRefreshTimer(); _startAutoRefreshTimer();
} }