flutter Widget Element
May 29, 2023
Element #
abstract class Element extends DiagnosticableTree implements BuildContext
package:flutter/src/widgets/framework.dart
An instantiation of a [Widget] at a particular location in the tree. – 在树里的特定位置上的一个
Widget
的实例。Widgets describe how to configure a subtree but the same widget can be used to configure multiple subtrees simultaneously because widgets are immutable. An [Element] represents the use of a widget to configure a specific location in the tree. Over time, the widget associated with a given element can change, for example, if the parent widget rebuilds and creates a new widget for this location. –
...Widget
描述了如何配置一棵子树,但同一个Widget
可以被用来配置多棵相似的子树,因为Widget
是不可变的。一个Element
代表了一个Widget
配置在树里的特定位置的使用。随着时间变化,每个Widget
与一个可以改变的Element
关联。