我是靠谱客的博主 畅快高山,这篇文章主要介绍Flutter之Key简析,现在分享给大家,希望可以做个参考。

在博主《Flutter之GlobalKey详解》和《Flutter之Widget 更新机制原理浅析》中两篇博文中简单的说明了key的作用,这里在简单做个笔记(翻译子官方文档),加深自己对key的理解。

官方对于key的解释如下:

///Key对象是用作Widget、Element、SemanticsNode的标识符,也就是唯一ID
/// A [Key] is an identifier for [Widget]s, [Element]s and [SemanticsNode]s.

///当newWidget和Element.widget的key相等时候,就满足了Element更新的条件之一。之二是
//oldWidget.runtimeType == newWidget.runtimeType,如果都满足的话,就可以将newWidget赋值给Element的Widget变量。
/// A new widget will only be used to update an existing element if its key is
/// the same as the key of the current widget associated with th

最后

以上就是畅快高山最近收集整理的关于Flutter之Key简析的全部内容,更多相关Flutter之Key简析内容请搜索靠谱客的其他文章。

本图文内容来源于网友提供,作为学习参考使用,或来自网络收集整理,版权属于原作者所有。
点赞(119)

评论列表共有 0 条评论

立即
投稿
返回
顶部