Skip to content

Bring projects, wikis, and teams together with AI. AppFlowy is the AI collaborative workspace where you achieve more without losing control of your data. The leading open source Notion alternative.

fix: loading exception when switching workspace

Nathan10a536b1a2e3
diff --git a/frontend/appflowy_flutter/lib/shared/loading.dart b/frontend/appflowy_flutter/lib/shared/loading.dart
index f8d1c6fc86..3958601ed8 100644
--- a/frontend/appflowy_flutter/lib/shared/loading.dart
+++ b/frontend/appflowy_flutter/lib/shared/loading.dart
@@ -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;
}
diff --git a/frontend/appflowy_flutter/lib/workspace/presentation/home/menu/sidebar/workspace/sidebar_workspace.dart b/frontend/appflowy_flutter/lib/workspace/presentation/home/menu/sidebar/workspace/sidebar_workspace.dart
index 50ea9d83c7..07a5aeec4e 100644
--- a/frontend/appflowy_flutter/lib/workspace/presentation/home/menu/sidebar/workspace/sidebar_workspace.dart
+++ b/frontend/appflowy_flutter/lib/workspace/presentation/home/menu/sidebar/workspace/sidebar_workspace.dart
@@ -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;
}