What is the Expanded vs Flexible widget difference?

Why Interviewers Ask This

This is a classic screening question for Flutter roles. Hiring managers ask it early in interviews to gauge your baseline understanding and determine if you can communicate technical concepts clearly.

Answer

Both Expanded and Flexible are used inside a Row or Column to control how children share space. Expanded forces its child to fill all remaining space (it uses FlexFit.tight). Flexible allows its child to be smaller than the allocated space — the child can choose its own size up to the available space (it uses FlexFit.loose by default). Use Flexible when you want the child to shrink-wrap its content but still participate in flex layout.

Common Mistake

Many candidates answer correctly but can't explain the 'why'. Always be prepared to justify your answer with a concrete example or use case from your Flutter experience.