How Widgets are rendered

Really good video

How Flutter renders Widgets
At Google Developer Days China 2019, Andrew Fitz Gibbon and Matt Sullivan discuss how Flutter works under the hood, and dig deep into widgets, elements, and render objects. Stay tuned to gain a better understanding of Flutter, and build better apps! GDD China 2019 → https://goo.gle/2WMctu8 Flutter Create → https://goo.gle/2WNaG85 Learn everything about Flutter at → https://flutter.dev Subscribe! → https://goo.gle/Flutter
https://www.youtube.com/watch?v=996ZgFRENMs

Here we are going to focus on the Framework Layer which can be broken down into the following layers:

All Three Trees

Flutter’s framework actually manages not one, but three trees in parallel:

Here’s how a single widget works under the hood:

Types of Element

There are two types of elements:

  1. ComponentElement: A type of element that’s composed of other elements. This corresponds to composing widgets inside other widgets.
  1. RenderObjectElement: A type of element that holds a render object.

You can think of ComponentElement as a group of elements, and RenderObjectElement as a single element. Remember that each element contains a render object to perform widget painting, layout and hit testing.

Example

The image below shows an example of the three trees for the Card2 UI:

The element tree manages each widget instance and associates a render object to tell the framework how to render a particular widget.