Unhandled Exception: Looking up a deactivated widget’s ancestor is unsafe.
At this point the state of the widget’s element tree is no longer stable. To safely refer to a widget’s ancestor in its dispose() method, save a reference to the ancestor by calling inheritFromWidgetOfExactType() in the widget’s didChangeDependencies() method.
这是我在flutter代码中想弹出我的弹窗,但是没有正常弹出。这个是有context上下文没有起作用导致的。将传过来的context,之前加一个this.context放到dialog内可以正常弹出dialog。
Unhandled Exception: Looking up a deactivated widget‘s ancestor is unsafe.
最新推荐文章于 2024-05-31 14:57:42 发布
本文探讨了在Flutter中遇到的'Looking up a deactivated widget's ancestor is unsafe'错误,重点在于解决在关闭弹窗时如何正确引用祖先组件以确保代码安全。通过在didChangeDependencies方法中保存祖先引用,修复了context失效导致的Dialog显示问题。
871

被折叠的 条评论
为什么被折叠?



