What does the Expanded widget do?

Why Interviewers Ask This

Interviewers use this question to quickly assess whether a candidate has the foundational knowledge required for Flutter development. It reveals whether you understand the building blocks that more complex concepts rely on.

Answer

The Expanded widget makes its child fill all available space along the main axis of its parent Row or Column. If multiple Expanded widgets are used, the flex property determines how the available space is distributed proportionally — a child with flex: 2 gets twice the space of one with flex: 1. It is essential for creating responsive layouts that adapt to different screen sizes without hardcoding dimensions.

Common Mistake

A common mistake is memorizing definitions without understanding implications. When asked this question, go one level deeper — explain what happens when this concept is misused or ignored.