midFlutter
Explain constraints in Flutter.
Updated Apr 28, 2026
Short answer
In Flutter layout rule is: 'Constraints go down. Sizes go up. Parent sets position.'
Deep explanation
The parent widget passes layout constraints (min/max width and height) down to its children. The child determines its own size within those constraints and passes the size back up to the parent. Finally, the parent decides exactly where to position the child on the screen.
Real-world example
A Container trying to be 500px wide but being forced to be 300px because its parent device screen is only 300px wide.
Common mistakes
- Setting absolute `width` and `height` and assuming they will always be respected. They are overridden if parent constraints are strict.
Follow-up questions
- What is an UnconstrainedBox?
- What causes the 'RenderFlex overflowed' error?