Sample questions
Question 1Easy
What is a common way to put a fixed 16-pixel vertical gap between two widgets in a Column?
Spacer(flex: 16)Gap.vertical(16)Padding(height: 16)SizedBox(height: 16)
Answer: D. SizedBox(height: 16)
Explanation
A SizedBox with only a height is an empty box of that size. Spacer takes a share of free space, not a fixed size.
Step-by-step solution
- A
SizedBox creates a fixed-size empty box. - Setting
height: 16 makes it 16 pixels tall. - Placing it in a
Column adds a 16-pixel gap. - The final answer is
SizedBox(height: 16).
Why the other options are wrong
- A. Spacer(flex: 16) gives flexible space that grows to fill, not a fixed 16-pixel gap.
- B. Gap.vertical comes from a third-party package, not core Flutter, so it is not the common built-in way.
- C. Padding has no height parameter; it takes EdgeInsets, so Padding(height: 16) does not compile.
Tip: Use SizedBox for fixed gaps and Spacer for flexible space.
Question 2Easy
In a Column, what does mainAxisAlignment control?
- The order in which the children are painted on screen
- How children are placed horizontally across the width
- The text alignment inside each Text child of the Column
- How children are placed vertically
Answer: D. How children are placed vertically
Explanation
A Column's main axis is vertical, so mainAxisAlignment positions children top to bottom; crossAxisAlignment handles horizontal placement.
Step-by-step solution
- MainAxisAlignment controls layout along the main axis of the Column.
- Column's main axis is vertical, so mainAxisAlignment places children vertically.
- CrossAxisAlignment handles horizontal alignment within the Column.
- Option D describes how children are placed vertically.
- Final answer: How children are placed vertically.
Why the other options are wrong
- A. Paint order follows the child list, and mainAxisAlignment does not control it.
- B. Horizontal placement across the width is crossAxisAlignment in a Column, not mainAxisAlignment.
- C. Text alignment is set on the Text widget itself, not by a Column's mainAxisAlignment.
Tip: Remember: Column's main axis is vertical, so mainAxisAlignment controls vertical alignment.
Question 3Easy
How do Row and Column arrange their children?
- Both stack children on top of each other
- Row vertically, Column horizontally
- Row horizontally, Column vertically
- Both wrap children onto new lines when they run out of space
Answer: C. Row horizontally, Column vertically
Explanation
Row's main axis is horizontal and Column's main axis is vertical. Neither wraps; use Wrap for that.
Step-by-step solution
- Row arranges children horizontally.
- Column arranges children vertically.
- Row's main axis is horizontal, so it places items side by side.
- Column's main axis is vertical, so it stacks items top to bottom.
- Correct answer: Row horizontally, Column vertically.
Why the other options are wrong
- A. Column does not stack children on top of each other; it lays them out in a vertical line.
- B. This swaps the axes: Row goes horizontally and Column vertically, not the other way round.
- D. Neither wraps onto new lines; that is Wrap's behaviour, while Row and Column stay in one line.
Tip: Remember: Row is horizontal, Column is vertical.
Question 4Easy
Which widget is meant purely for adding empty space around a single child?
- Align
- Center
- Expanded
- Padding
Answer: D. Padding
Explanation
Padding insets its child by the given EdgeInsets. Container can also add padding, but Padding is the dedicated, lighter widget.
Step-by-step solution
- Padding adds empty space around its single child.
- It uses EdgeInsets to control spacing on all sides.
- Expanded stretches its child to fill available space.
- Center centers its child within itself but doesn't add padding.
- Align is used for positioning children in a flexible layout.
- Final answer: Padding.
Why the other options are wrong
- A. Align positions its child within available space; it does not purely add padding around it.
- B. Center places its child in the middle; it adds no spacing around the child.
- C. Expanded makes its child fill free space along the flex axis; it does not add empty space.
Tip: Use Padding when you need to add space around a single widget.
Question 5Medium
How does Flexible (with its default fit) differ from Expanded?
- There is no difference; Expanded is just the deprecated name for Flexible
- Flexible only works in Column, and Expanded only works inside Row
- Expanded lets the child be smaller than its share; Flexible forces it to fill
- Flexible lets the child be smaller than its share; Expanded forces it to fill
Answer: D. Flexible lets the child be smaller than its share; Expanded forces it to fill
Explanation
Expanded is Flexible with fit: FlexFit.tight. The default Flexible uses FlexFit.loose, so the child may use less than its allotted space.
Step-by-step solution
- Flexible has default fit as FlexFit.loose, allowing child to be smaller than share.
- Expanded uses FlexFit.tight, forcing child to fill its allocated space.
- So Flexible lets child be smaller; Expanded forces it to fill.
- This matches option D exactly.
- Final answer: Flexible lets the child be smaller than its share; Expanded forces it to fill.
Why the other options are wrong
- A. Expanded and Flexible differ in fit; Expanded is not just a renamed Flexible.
- B. Both work in Row and Column alike; neither is restricted to one parent axis.
- C. The fit is reversed: Expanded uses tight fit to fill, while Flexible uses loose fit.
Tip: Remember: Flexible = loose fit (can shrink), Expanded = tight fit (must fill).
Question 6Medium
What does crossAxisAlignment: CrossAxisAlignment.stretch do in a Column?
- Forces each child to fill the Column's full height
- Spreads the children evenly from top to bottom
- Forces each child to fill the Column's width
- Centers every child horizontally inside the Column
Answer: C. Forces each child to fill the Column's width
Explanation
The cross axis of a Column is horizontal; stretch gives children tight width constraints equal to the Column's width.
Step-by-step solution
- In a Column, the cross axis runs horizontally.
- CrossAxisAlignment.stretch gives children tight constraints on the cross axis.
- Tight constraints make each child expand to the Column's maximum width.
- Forces each child to fill the Column's width.
Why the other options are wrong
- A. Stretch acts on the cross axis, which is horizontal in a Column, so height is not stretched.
- B. Spreading children evenly is a mainAxisAlignment setting, which stretch does not control.
- D. Centering is crossAxisAlignment.center; stretch makes children fill the width, not center them.
Tip: Use CrossAxisAlignment.stretch to make children fill the Column's width.
Question 7Medium
Which phrase summarises Flutter's layout rule?
- Parents copy their size to all children, which then set position
- Constraints go down, sizes go up, parents set position
- Sizes go down, constraints go up, children set their own position
- Every widget measures the screen and then picks its own size
Answer: B. Constraints go down, sizes go up, parents set position
Explanation
A parent passes constraints to each child, the child picks a size within them and reports it back, and the parent decides where to place the child.
Step-by-step solution
- Parents pass constraints to children.
- Children pick size within constraints and report it.
- Parent uses this info to set child's position.
- Constraints go down, sizes go up, parents set position.
- Final answer: Constraints go down, sizes go up, parents set position.
Why the other options are wrong
- A. Parents do not copy their size to children; children choose their own size within given constraints.
- C. The rule goes the other way: constraints flow down and sizes flow up, not sizes down.
- D. Widgets do not measure the screen to pick their size; the parent's constraints set the limits.
Tip: Remember: constraints flow down, sizes flow up, and positioning is handled by parents.
Question 8Medium
A Row shows yellow-and-black stripes at its right edge in debug mode. What does that mean?
- A child widget threw an exception while running its build
- Its children are wider than the space available (overflow)
- The Row is using an image that has not finished loading yet
- The app is running in release mode with warnings enabled
Answer: B. Its children are wider than the space available (overflow)
Explanation
The striped bar is the RenderFlex overflow indicator. Fixes include Expanded or Flexible around a child, smaller content, or Wrap/scrolling.
Step-by-step solution
- Yellow-and-black stripes show layout issues in debug mode.
- This indicates a child widget is overflowing the Row's space.
- Overflow happens when children are wider than available space.
- Use Expanded or Flexible to fix layout overflow.
- Final answer: Its children are wider than the space available (overflow)
Why the other options are wrong
- A. An exception would show a red error screen in debug mode, not yellow and black warning stripes.
- C. Image loading does not produce these stripes; a Row with children too wide does.
- D. Release mode does not show debug stripes; this overflow marker appears only in debug builds.
Tip: Check for overflow by looking at debug stripes.
Question 9Hard
A Row containing an Expanded child is placed inside a horizontal SingleChildScrollView. What happens?
- The Expanded child is quietly converted to a Flexible with loose fit
- The Expanded child grows to fill the entire scrollable content area
- Layout error: flex children cannot be laid out in an unbounded width
- The Row scrolls normally and the Expanded child takes no space at all
Answer: C. Layout error: flex children cannot be laid out in an unbounded width
Explanation
A horizontal scroll view gives its child infinite width, so there is no remaining space to share among flex children. Flutter reports a RenderFlex error.
Step-by-step solution
- A horizontal SingleChildScrollView gives its child infinite width.
- Row attempts to layout its flex children within that width.
- Expanded requires finite remaining space, but the width is unbounded.
- Layout error: flex children cannot be laid out in an unbounded width.
Why the other options are wrong
- A. Expanded is not converted to Flexible; it stays Expanded, and the error comes from the unbounded width.
- B. Expanded has no finite width to fill inside an unbounded scroll, so it does not grow to the content area.
- D. The Row does not scroll normally here; the flex layout fails and the app shows an error instead.
Tip: Avoid using Expanded inside a scrollable that provides infinite space.
Question 10Hard
A card should switch between a one-column and a two-column layout depending on how much width its parent gives it, not the screen width. Which widget fits best?
- AspectRatio
- OrientationBuilder
- MediaQuery
- LayoutBuilder
Answer: D. LayoutBuilder
Explanation
LayoutBuilder passes the parent's constraints to its builder. MediaQuery reports the whole screen or window size, which can differ from the space the card actually gets.
Step-by-step solution
- The card needs its parent's width, not the screen's.
- LayoutBuilder gives the parent's constraints.
Why the other options are wrong
- A. AspectRatio sets a ratio.
- B. OrientationBuilder reacts to device orientation.
- C. MediaQuery gives screen size.
Tip: Local size = LayoutBuilder.
Practise all 15 questions free
The full question bank with timed practice, progress tracking and Vidya, your AI tutor. Free, no ads.
Open this topic in the app →