Flutter 每日翻译之 Widget

Describes the configuration for an [Element].

描述元素的配置

Widgets are the central class hierarchyin the Flutter framework.

组件是 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, considerusing a

StatefulWidget\], which creates a \[State\] object (via \[StatefulWidget.createState\]) whenever it is inflated into an element and **incorporated**into the tree. 控件自身拥有不可变状态(他们的属性必须是final),如果你希望关联到一个可变状态的控件,请**考虑**使用\[StatefulWidget\],创建一个\[State\] 类(通过StatefulWidget.createState),不管如何,他会被解析成元素**合并**到树中 **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. **给定的小部件**可以在树中包含零次或多次。**特别是**给定的小部件可以多次放置在树中。每次一个小部件被放置在树中,它被解析成一个\[Element\],这意味着一个多次合并到树中的小部件将被充气 很多次了。 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. \[key\]属性控制一个小部件如何替换树中的另一个小部件。如果两个小部件的\[runtimeType\]和\[key\]属性分别为\[operator==\],则新小部件**依次**通过更新底层元素(即通过调用\[element\])来替换旧小部件。用新的小部件更新)。**否则**,将从树中删除旧元素,将新小部件解析为元素,并将新元素插入到树中。 \[StatefulWidget\] and \[State\], for widgets that can build differently**several times**over their lifetime. \[StatefulWidget\]和\[State\],用于在其生命周期中可以**多次**构建不同的小部件。 \[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. \[StatelessWidget\],用于在给定**特定**配置和**环境**状态时始终以相同方式构建的小部件。

相关推荐
默默_david2 小时前
14.5 绘制(一)绘制原理及Layer——问答
flutter
LinXunFeng16 小时前
Flutter 拖拉对比组件,换装图片前后对比必备
前端·flutter·开源
2501_9197490316 小时前
配置flutter鸿蒙的环境和创建并运行第一个flutter鸿蒙项目【精心制作】
flutter·华为·harmonyos
YUFENGSHI.LJ18 小时前
Flutter 如何使用fvm进行多项目sdk管理
flutter
开心-开心急了20 小时前
关于Flutter与Qt for python 的一些技术、开源、商用等问题
开发语言·python·qt·flutter
猫林老师1 天前
Flutter for HarmonyOS开发指南(四):国际化与本地化深度实践
flutter·华为·harmonyos
猫林老师1 天前
Flutter for HarmonyOS 开发指南(一):环境搭建与项目创建
flutter·华为·harmonyos
sunly_2 天前
Flutter:视频预览功能
javascript·flutter·音视频
勤劳打代码2 天前
条分缕析 —— 通过 Demo 深入浅出 Provider 原理
flutter·面试·dart
2501_915918412 天前
Flutter 加固方案对比与实战,多工具组合的跨平台安全体系(Flutter App 加固/IPA 成品混淆/Ipa Guard CLI/自动化安全流程)
安全·flutter·ios·小程序·uni-app·自动化·iphone