Skip to main content
InterviewHubPRO
Section Overview
Q21

Question 21 of 50

Part 3: Advanced Internals, Scale & Production Patterns (Senior / Lead)

42%
Flutter & Dart (50 Qs)•Part 3: Advanced Internals, Scale & Production Patterns (Senior / Lead)

How does Layout work in Flutter: "Constraints Go Down, Sizes Go Up, Parent Sets Position"?

senior LevelCode ExampleflutterAdvanced Internals

In Simple Words: The golden rule of the Flutter layout pipeline:

  1. Constraints Go Down: A parent widget passes minimum and maximum width/height constraints (BoxConstraints) down to its child.
  2. Sizes Go Up: The child determines its own dimensions within those constraints and passes its calculated Size back up to the parent.
  3. Parent Sets Position: The parent places the child at an $(x, y)$ coordinate position within its coordinate space.
  • An unconstrained widget (e.g. placing ListView inside Column without Expanded) causes the fatal crash: Vertical viewport was given unbounded height.
text
The Flutter Layout Rule:
      [Parent Widget]
       │           ▲
       │ (Constraints: Min/Max Width & Height)
       ▼           │ (Calculated Size: Width & Height)
      [Child Widget]
       │
 (Parent places Child at x, y position)