Libertarian
Libertarian

Reputation: 131

How does flutter size and position UI elements (widgets)?

How does flutter size and position UI elements (widgets)? Is it determined by parent widget or by child widget itself? I want to know, what is the algorithm being used under the hood, when it processes the widget tree.

Upvotes: 0

Views: 185

Answers (1)

Andrei Matveiakin
Andrei Matveiakin

Reputation: 1818

This is a great article on the topic: https://flutter.dev/docs/development/ui/layout/constraints

TL;DR. Widget gets size constraints from the parent. Widget chooses its size (within the constraints) and reports back to parent. Parent positions the widget.

Upvotes: 3

Related Questions