Flutter · One codebase, native feel
How do Flutter's core layout widgets work together?
Short answer
Parents pass constraints down and children return sizes up. Containers, padding, alignment and size boxes adjust constraints and positioning, and the parent decides where the child is placed.
Flutter layout is constraint-based, not coordinate-based. A widget receives a BoxConstraints with minimum and maximum width and height, picks a size that satisfies them, and reports that size to its parent. The parent then positions the child. Understanding this explains most overflow and unbounded-constraint errors.
Scaffold(
body: SafeArea(
child: Padding(
padding: const EdgeInsets.all(16),
child: Column(
crossAxisAlignment: CrossAxisAlignment.start,
children: const [
Text('Account'),
SizedBox(height: 8),
Card(child: ListTile(title: Text('Billing'))),
],
),
),
),
)- Padding reduces the constraints given to its child and adds the padding back to its own size
- SizedBox forces a specific size when constraints allow
- Container combines padding, margin, decoration, alignment and constraints
- Align and Center place a child inside available space
- Expanded and Flexible only work inside Flex widgets such as Row and Column
Debugging layout errors
An unbounded constraint error means a widget that wants infinite size is inside a scrollable or another unbounded parent. A RenderFlex overflow means the children's minimum sizes exceed the available main-axis space. Fix the constraint chain rather than hiding the error with clipping.
Follow-ups you should expect
Interviewers use these to check whether the first answer was understanding or memorisation.
- 1Why does a Column inside a ListView throw an unbounded height error?
- 2What is the difference between Padding and Container?
- 3How does SafeArea affect layout?
- 4What does a RenderFlex overflow mean?
Say it in the interview
Flutter layout is constraints down, sizes up. Each widget gets a constraint range, chooses a size, and the parent positions it. Padding, SizedBox and Container change the constraints or add space, while Align places a child inside what is available. Most layout bugs come from the constraint chain, so I inspect that instead of clipping the symptom.
Use this as a model, not a script. Saying it in your own words is what makes it survive follow-up pressure.
Related questions
Reading is step one
Now say it out loud.
Understanding an answer and delivering it under pressure are different skills. Rehearse this topic in a live Flutter mock interview and get scored feedback on depth, clarity and confidence.