fix: loading exception when switching workspace

This commit is contained in:
Nathan 2025-04-21 16:37:02 +08:00
parent 65b7916a6a
commit 10a536b1a2
2 changed files with 13 additions and 4 deletions

View File

@ -40,7 +40,11 @@ class Loading {
void stop() {
if (loadingContext != null) {
Navigator.of(loadingContext!).pop();
if (loadingContext!.mounted) {
if (Navigator.canPop(loadingContext!)) {
Navigator.of(loadingContext!).pop();
}
}
loadingContext = null;
}

View File

@ -32,7 +32,10 @@ class _SidebarWorkspaceState extends State<SidebarWorkspace> {
@override
void dispose() {
onHover.dispose();
if (loadingIndicator != null) {
loadingIndicator?.stop();
loadingIndicator = null;
}
super.dispose();
}
@ -100,8 +103,10 @@ class _SidebarWorkspaceState extends State<SidebarWorkspace> {
if (isLoading) {
loadingIndicator ??= Loading(context)..start();
return;
} else {
loadingIndicator?.stop();
} else if (loadingIndicator != null) {
if (mounted) {
loadingIndicator?.stop();
}
loadingIndicator = null;
}