zefyr icon indicating copy to clipboard operation
zefyr copied to clipboard

Looking up a deactivated widget's ancestor is unsafe

Open HLGB26 opened this issue 5 years ago • 1 comments

I am getting this error "Looking up a deactivated widget's ancestor is unsafe."

To safely refer to a widget's ancestor in its dispose() method, save a reference to the ancestor by calling dependOnInheritedWidgetOfExactType() in the widget's didChangeDependencies() method.

I am using zefyr editor. See this for minimal example https://github.com/memspace/zefyr/issues/341

HLGB26 avatar Jul 25 '20 17:07 HLGB26

Add AutomaticKeepAliveClientMixin to your stateful widget, and add

@override
  bool get wantKeepAlive => true;

as well as

super.build(context); 

in widget's build method.

youssef-fk avatar Sep 27 '20 10:09 youssef-fk