Challenge - 5 Problems
ListView Master
Get all challenges correct to earn this badge!
Test your skills under time pressure!
❓ ui_behavior
intermediate2:00remaining
What does this ListView display?
Consider this Flutter code snippet. What will the ListView show on the screen?
Flutter
ListView(
children: [
Text('Apple'),
Text('Banana'),
Text('Cherry'),
],
)Attempts:
2 left
💡 Hint
ListView by default scrolls vertically and accepts children widgets.
✗ Incorrect
ListView with children shows them vertically by default. No error occurs. Text widgets display their text.
📝 Syntax
intermediate2:00remaining
Which option correctly creates a ListView with 3 items using builder?
Choose the correct Flutter code to create a ListView with 3 Text items: 'One', 'Two', 'Three' using ListView.builder.
Attempts:
2 left
💡 Hint
The itemBuilder function parameters are (BuildContext, int). The property is itemCount, not count.
✗ Incorrect
Option A uses correct parameter order and property names. Others have wrong parameter order, property names, or missing itemBuilder.
❓ lifecycle
advanced2:00remaining
What happens if you update the list data but forget to call setState() in a StatefulWidget?
In a StatefulWidget, you update the list used by ListView but do not call setState(). What is the visible effect?
Attempts:
2 left
💡 Hint
setState() tells Flutter to redraw the widget with new data.
✗ Incorrect
Without setState(), Flutter does not know data changed, so UI stays the same.
advanced
2:00remaining
How to navigate to a new screen when tapping a ListView item?
You want to open a new screen when a user taps an item in ListView. Which code snippet correctly does this?
Attempts:
2 left
💡 Hint
Use onTap for ListTile tap events and Navigator.push to go to a new screen.
✗ Incorrect
Option C uses onTap and Navigator.push correctly. B uses wrong event onPressed. A and C pop the current screen instead of pushing a new one.
🔧 Debug
expert2:00remaining
Why does this ListView cause a vertical overflow error?
This code causes a vertical overflow error when run. Why?
Flutter
Column(
children: [
Text('Header'),
ListView(
shrinkWrap: true,
children: List.generate(50, (index) => Text('Item $index')),
),
],
)Attempts:
2 left
💡 Hint
ListView tries to expand infinitely inside a Column without height constraints.
✗ Incorrect
ListView inside Column needs a fixed height or to be wrapped in Expanded/Flexible to avoid overflow.