fix: guard setState/context against disposed widget

This commit is contained in:
edde746
2026-04-21 22:29:57 +02:00
parent eb49ead83b
commit 557ef69697
3 changed files with 3 additions and 0 deletions
+1
View File
@@ -118,6 +118,7 @@ class _AuthScreenState extends State<AuthScreen> {
Navigator.pushReplacement(context, fadeRoute(MainScreen(client: result.firstClient!)));
} catch (e) {
appLogger.e('Failed to connect to servers', error: e);
if (!mounted) return;
setState(() {
_isAuthenticating = false;
_errorMessage = t.serverSelection.failedToLoadServers(error: e);
+1
View File
@@ -570,6 +570,7 @@ class _DiscoverScreenState extends State<DiscoverScreen>
appLogger.d('Discover content loaded successfully');
} catch (e) {
appLogger.e('Failed to load discover content', error: e);
if (!mounted) return;
setState(() {
_errorMessage = 'Failed to load content: $e';
_isLoading = false;
@@ -132,6 +132,7 @@ class _LibrariesScreenState extends State<LibrariesScreen>
// Initialize with libraries from the provider
WidgetsBinding.instance.addPostFrameCallback((_) {
if (!mounted) return;
_initializeWithLibraries();
});
}