Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Fix/free dependents #1142

Merged
merged 18 commits into from
Feb 9, 2022
Merged

Fix/free dependents #1142

merged 18 commits into from
Feb 9, 2022

Conversation

answershuto
Copy link
Member

close #1129

报错原因是 InheritedWidget 在收集的依赖在 Widget 对应的 element 在在销毁或者隐藏状态下没有调用 deactivate 去清除相应的依赖,导致断言检测异常直接抛出错误。处理的方式是需要在 Kraken Widiget 相应的生命周期中调用所有下属自定义 Widget 的 deactivate 方法。

wssgcg1213
wssgcg1213 previously approved these changes Feb 9, 2022
@answershuto answershuto requested a review from yuanyan February 9, 2022 08:57
@yuanyan yuanyan merged commit 37c86ed into main Feb 9, 2022
@yuanyan yuanyan deleted the fix/free_dependents branch February 9, 2022 09:14
@donfo
Copy link

donfo commented Mar 17, 2022

@answershuto 自己定义组件在切换页面后报出这个错,貌似在有些情况下element.renderObjectElement是null

element.deactivate();

════════ Exception caught by widgets library ═══════════════════════════════════
'package:kraken[/src/widget/widget_to_element_adaptor.dart]()': Failed assertion: line 268 pos 12: 'renderObjectElement != null': is not true.````

@answershuto
Copy link
Member Author

写个 issue 然后提供一个 demo 吧,是最新的 main 上面的问题吗? @donfo

@donfo
Copy link

donfo commented Mar 17, 2022

写个 issue 然后提供一个 demo 吧,是最新的 main 上面的问题吗? @donfo

assert(renderObjectElement != null);

我把这行断言注释了就正常了, 不知道会带来其它影响不

@donfo
Copy link

donfo commented Mar 17, 2022

写个 issue 然后提供一个 demo 吧,是最新的 main 上面的问题吗? @donfo

是最新的版本,kraken: ^0.10.2+1

@answershuto
Copy link
Member Author

看起来还是生命周期的某个环节有问题,注释掉了可以正常 work ,但是状态依旧是异常的,可能会产生泄漏等影响。可以给我一个最小化的 demo 我来排查一下。 @donfo

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

自定义元素在Kraken退出后报错
4 participants