Challenge - 5 Problems
Wrap Widget Master
Get all challenges correct to earn this badge!
Test your skills under time pressure!
❓ ui_behavior
intermediate2:00remaining
How does the Wrap widget arrange children?
Given a Wrap widget with several children that exceed the screen width, how does it arrange these children?
Attempts:
2 left
💡 Hint
Think about how text wraps in a paragraph when it reaches the edge.
✗ Incorrect
The Wrap widget arranges children horizontally and moves to the next line when there is no more horizontal space, similar to how words wrap in a paragraph.
📝 Syntax
intermediate2:00remaining
Identify the correct Wrap widget syntax
Which of the following Flutter code snippets correctly creates a Wrap widget with three Text children?
Attempts:
2 left
💡 Hint
Remember the children property expects a list of widgets.
✗ Incorrect
The children property must be a list of widgets enclosed in square brackets []. Option B correctly uses children: [ ... ].
❓ ui_behavior
advanced2:00remaining
What is the effect of changing the spacing property in Wrap?
If you set spacing: 20.0 in a Wrap widget, what will happen?
Attempts:
2 left
💡 Hint
Spacing controls the gap between items in the main axis direction.
✗ Incorrect
The spacing property adds horizontal space between children in the Wrap's main axis (usually horizontal).
❓ lifecycle
advanced2:00remaining
How does Wrap widget behave on screen rotation?
When the device rotates from portrait to landscape, how does the Wrap widget adjust its children layout?
Attempts:
2 left
💡 Hint
Think about how responsive layouts adapt to screen size changes.
✗ Incorrect
Wrap widget dynamically adapts to available width and reflows children when screen size changes, such as on rotation.
🔧 Debug
expert2:00remaining
Why does this Wrap widget cause overflow error?
Consider this code snippet:
Wrap(
direction: Axis.vertical,
children: [
Container(width: 100, height: 100, color: Colors.red),
Container(width: 100, height: 100, color: Colors.blue),
Container(width: 100, height: 100, color: Colors.green),
],
)
Why might this cause an overflow error on a small screen?
Attempts:
2 left
💡 Hint
Think about how vertical Wrap arranges children and screen height limits.
✗ Incorrect
When Wrap direction is vertical, children are arranged in columns and wrap horizontally. If vertical space is limited, children may overflow vertically causing errors.