mirror of
https://github.com/AppFlowy-IO/AppFlowy.git
synced 2025-09-27 09:26:47 +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> {
|
class _CommandPaletteControllerState extends State<_CommandPaletteController> {
|
||||||
late final ValueNotifier<bool> _toggleNotifier = widget.notifier;
|
late ValueNotifier<bool> _toggleNotifier = widget.notifier;
|
||||||
bool _isOpen = false;
|
bool _isOpen = false;
|
||||||
|
|
||||||
@override
|
@override
|
||||||
@ -71,6 +71,16 @@ class _CommandPaletteControllerState extends State<_CommandPaletteController> {
|
|||||||
super.dispose();
|
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() {
|
void _onToggle() {
|
||||||
if (_toggleNotifier.value && !_isOpen) {
|
if (_toggleNotifier.value && !_isOpen) {
|
||||||
_isOpen = true;
|
_isOpen = true;
|
||||||
|
Loading…
x
Reference in New Issue
Block a user