您当前的位置: 首页 >  flutter

郭梧悠

暂无认证

  • 3浏览

    0关注

    402博文

    0收益

  • 0浏览

    0点赞

    0打赏

    0留言

私信
关注
热门博文

Flutter之Key简析

郭梧悠 发布时间:2022-05-06 19:19:40 ,浏览量:3

在博主《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
关注
打赏
1663674776
查看更多评论
立即登录/注册

微信扫码登录

0.0367s