停用和处置之间的区别? [英] Difference Between Deactivate and Dispose?

查看:142
本文介绍了停用和处置之间的区别?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

在Flutter中,StatefulWidget具有 dispose() deactivate()。它们有什么不同?

In Flutter, StatefulWidget has dispose() and deactivate(). How are they different?

推荐答案

dispose 是确定的。 停用不是。

停用小部件 可能会被丢弃。但这并不能保证。

deactivate is called when a widget may be disposed. But that is not guaranteed.

通常会调用停用但不处理的情况。 ,是使用 GlobalKey 在小部件树中移动小部件时。

A typical situation where deactivate is called but not dispose,is when moving widgets in the widget tree using a GlobalKey.

这篇关于停用和处置之间的区别?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆