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:
parent
b3142387f7
commit
1908544698
|
|
@ -201,8 +201,10 @@ class _ProfilePageState extends ConsumerState<ProfilePage> {
|
||||||
_checkAndStartWalletPolling();
|
_checkAndStartWalletPolling();
|
||||||
});
|
});
|
||||||
_loadAppInfo();
|
_loadAppInfo();
|
||||||
// 通知数量(轻量级请求)
|
// 通知数量(轻量级请求)- 延迟到下一帧执行,避免在 build 期间修改 provider
|
||||||
_loadUnreadNotificationCount();
|
WidgetsBinding.instance.addPostFrameCallback((_) {
|
||||||
|
_loadUnreadNotificationCount();
|
||||||
|
});
|
||||||
// 启动定时刷新(可见区域的数据)
|
// 启动定时刷新(可见区域的数据)
|
||||||
_startAutoRefreshTimer();
|
_startAutoRefreshTimer();
|
||||||
}
|
}
|
||||||
|
|
|
||||||
Loading…
Reference in New Issue