fix: guard setState/context against disposed widget
This commit is contained in:
@@ -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);
|
||||
|
||||
@@ -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();
|
||||
});
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user