Flutter

flutter Widget Element

May 29, 2023
Flutter, Widget, Element
Flutter

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关联。

...