mirror of
https://github.com/AppFlowy-IO/AppFlowy.git
synced 2025-09-26 17:03:05 +00:00
fix: notifier disposed but in use (#6586)
This commit is contained in:
parent
6340174927
commit
1d9876a6eb
@ -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;
|
||||
|
Loading…
x
Reference in New Issue
Block a user