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: notifier disposed but in use (#6586)

Mathias Mogensen1d9876a6eb65
diff --git a/frontend/appflowy_flutter/lib/workspace/presentation/command_palette/command_palette.dart b/frontend/appflowy_flutter/lib/workspace/presentation/command_palette/command_palette.dart
index 8e418ca37f..8eb7765c3a 100644
--- a/frontend/appflowy_flutter/lib/workspace/presentation/command_palette/command_palette.dart
+++ b/frontend/appflowy_flutter/lib/workspace/presentation/command_palette/command_palette.dart
@@ -56,7 +56,7 @@ class _CommandPaletteController extends StatefulWidget {
}
class _CommandPaletteControllerState extends State<_CommandPaletteController> {
- late final ValueNotifier<bool> _toggleNotifier = widget.notifier;
+ late ValueNotifier<bool> _toggleNotifier = widget.notifier;
bool _isOpen = false;
@override
@@ -71,6 +71,16 @@ class _CommandPaletteControllerState extends State<_CommandPaletteController> {
super.dispose();
}
+ @override
+ void didUpdateWidget(_CommandPaletteController oldWidget) {
+ if (oldWidget.notifier != widget.notifier) {
+ oldWidget.notifier.removeListener(_onToggle);
+ _toggleNotifier = widget.notifier;
+ _toggleNotifier.addListener(_onToggle);
+ }
+ super.didUpdateWidget(oldWidget);
+ }
+
void _onToggle() {
if (_toggleNotifier.value && !_isOpen) {
_isOpen = true;