Flutter 的渲染涉及三棵树——Widget tree(配置)、Element tree(实例化、受管的 widgets)和 RenderObject tree(布局和绘制)。理解这个管道阐明了 Flutter 如何有效地将 widgets 转换为像素。
三棵树
WIDGET tree → immutable CONFIGURATION (what you write: the description of the UI)
→ cheap to create/recreate; rebuilt often (build() returns new widgets)
ELEMENT tree → the INSTANTIATED widgets; manages lifecycle and LINKS widgets to render
objects; PERSISTS across rebuilds (this is the key to efficiency)
RENDEROBJECT tree → does the actual LAYOUT, PAINTING, and hit-testing (the heavy objects)
→ expensive; REUSED and updated (not recreated) across rebuilds
