Professional Documents
Culture Documents
Lec 3
Lec 3
Lecture 3
➢ In Flutter, everything is a widget. Whether it’s a button, a text element, a layout, or even
the entire app, they’re all represented by widgets.
➢ Widgets are organized in a hierarchical structure, meaning they build upon each other to
create the entire user interface of your app.
➢Like Legos, you can mix and match widgets to create something amazing.
Understanding Flutter Widgets(cont.)
▪Flutter’s declarative nature makes it super easy to build a UI with widgets.
▪You can think of widgets as a function of UI. Given a state, the build() method of a widget
constructs the widget UI.
Understanding Flutter Widgets(cont.)
Common Widgets:
➢ Container: A versatile widget that combines common painting, positioning, and sizing properties.
▪ Think of it as a family tree for your UI components, where each widget is a node
connected to its parent and children.
➢ You build the widget tree using the build method within widget objects.
➢ When a widget’s build method returns more widgets, those new widgets become child
nodes in the tree.
➢ The tree grows as you add more widgets, creating a visual representation of your app’s UI.
Widget tree
Example:
Element tree
▪What Is the Element Tree?
➢Each element is associated with a single widget, and the element tree is a one-to-one
mapping of widgets to elements.
➢ When you create a widget, Flutter automatically creates a corresponding element for it.
➢ Elements are lightweight objects that handle the rendering, layout, and interaction of
widgets.
Element tree
Example:
Render tree
▪What Is the Rendering Tree?
➢ The render tree is created from the element tree and describes the geometry of UI components.
➢ When you build a widget tree in Flutter, each widget corresponds to an element.
➢ Elements are lightweight objects that manage the rendering, layout, and interaction of widgets.
➢ The render tree is constructed from these elements during the layout phase.
(Widget ,Element, Render) trees
▪Example:
ANY QUESTIONS?