三棵树

widget翻译

1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
Describes the configuration for an [Element].

Widgets are the central class hierarchy in the Flutter framework. A widget
is an immutable description of part of a user interface. Widgets can be
inflated into elements, which manage the underlying render tree.

Widgets themselves have no mutable state (all their fields must be final).
If you wish to associate mutable state with a widget, consider using a
[StatefulWidget], which creates a [State] object (via
[StatefulWidget.createState]) whenever it is inflated into an element and
incorporated into the tree.

A given widget can be included in the tree zero or more times. In particular
a given widget can be placed in the tree multiple times. Each time a widget
is placed in the tree, it is inflated into an [Element], which means a
widget that is incorporated into the tree multiple times will be inflated
multiple times.

The [key] property controls how one widget replaces another widget in the
tree. If the [runtimeType] and [key] properties of the two widgets are
[operator==], respectively, then the new widget replaces the old widget by
updating the underlying element (i.e., by calling [Element.update] with the
new widget). Otherwise, the old element is removed from the tree, the new
widget is inflated into an element, and the new element is inserted into the
tree.

See also:

* [StatefulWidget] and [State], for widgets that can build differently
several times over their lifetime.
* [InheritedWidget], for widgets that introduce ambient state that can
be read by descendant widgets.
* [StatelessWidget], for widgets that always build the same way given a
particular configuration and ambient state.
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
好的,我已经翻译了您的英文段落。请看下面的汉语版本。😊

Okay, I have translated your English paragraph. Please see the Chinese version below. 😊

/// 描述了[Element]的配置。
///
/// Widgets是Flutter框架中的核心类层次结构。一个widget是用户界面部分的不可变描述。Widgets可以被扩展成elements,它们管理底层的渲染树。
///
/// Widgets本身没有可变状态(它们的所有字段都必须是final)。如果您想要将可变状态与widget关联起来,请考虑使用[StatefulWidget],它在每次被扩展成element并加入到树中时,都会创建一个[State]对象(通过[StatefulWidget.createState])。
///
/// 一个给定的widget可以被包含在树中零次或多次。特别地,一个给定的widget可以被放置在树中多次。每次一个widget被放置在树中时,它都会被扩展成一个[Element],这意味着一个被加入到树中多次的widget将会被扩展多次。
///
/// [key]属性控制了一个widget如何替换树中的另一个widget。如果两个widget的[runtimeType]和[key]属性分别是[operator==],那么新的widget就会通过更新底层的element(即通过调用[Element.update]并传入新的widget)来替换旧的widget。否则,旧的element就会从树中移除,新的widget就会被扩展成一个element,并且新的element就会插入到树中。
///
/// 另请参阅:
///
/// * [StatefulWidget]和[State],用于可以在其生命周期内以不同方式构建多次的widgets。
/// * [InheritedWidget],用于引入可以被后代widgets读取的环境状态。
/// * [StatelessWidget],用于始终以相同方式构建(给定特定配置和环境状态)的widgets。

Source: Conversation with Bing, 2/27/2023(1) . https://bing.com/search?q=translate+to+Chinese Accessed 2/27/2023.
(2) Google Translate. https://translate.google.com/;) Accessed 2/27/2023.
(3) Google 翻譯. https://translate.google.com/?hl=zh-TW Accessed 2/27/2023.
(4) DeepL Translate: The world's most accurate translator. https://www.deepl.com/en/translator-mobile Accessed 2/27/2023.