Challenge - 5 Problems
SingleChildScrollView Master
Get all challenges correct to earn this badge!
Test your skills under time pressure!
❓ ui_behavior
intermediate2:00remaining
What is the output of this Flutter code with SingleChildScrollView?
Consider this Flutter widget tree. What will the user see and how will it behave?
Flutter
SingleChildScrollView(
child: Column(
children: List.generate(30, (index) => Text('Item $index')),
),
)Attempts:
2 left
💡 Hint
Think about what SingleChildScrollView does with a Column of many children.
✗ Incorrect
SingleChildScrollView allows its child to be bigger than the screen and scrolls vertically by default. The Column arranges children vertically. So the user sees all 30 items by scrolling.
❓ lifecycle
intermediate2:00remaining
What happens if you nest multiple SingleChildScrollView widgets vertically?
Given this widget tree, what is the expected scroll behavior?
SingleChildScrollView(
child: SingleChildScrollView(
child: Column(
children: [...],
),
),
)
Attempts:
2 left
💡 Hint
Think about how Flutter handles nested scroll views with the same scroll direction.
✗ Incorrect
Flutter disables inner scroll views when nested vertically to avoid scroll conflicts. Only the outer scroll view scrolls.
📝 Syntax
advanced2:00remaining
What error does this Flutter code produce?
Examine this code snippet:
SingleChildScrollView(
child: Column(
children: [
Container(height: 1000),
Expanded(child: Text('Hello'))
],
),
)
Attempts:
2 left
💡 Hint
Remember how Expanded works inside Column and scroll views.
✗ Incorrect
Expanded requires a bounded height from its parent. Inside SingleChildScrollView, Column has infinite height, so Expanded causes a runtime error.
advanced
2:00remaining
How to preserve scroll position when navigating back to a screen with SingleChildScrollView?
You have a screen with SingleChildScrollView showing a long list. When you navigate away and come back, the scroll resets to top. How to keep the scroll position?
Attempts:
2 left
💡 Hint
Think about how Flutter manages scroll positions with controllers.
✗ Incorrect
Using a ScrollController attached to SingleChildScrollView lets you save and restore scroll offset when navigating back.
🧠 Conceptual
expert2:00remaining
Why is SingleChildScrollView not recommended for very long lists?
You want to display a list of 1000 items. Why should you avoid using SingleChildScrollView with a Column for this?
Attempts:
2 left
💡 Hint
Think about how Flutter builds widgets inside SingleChildScrollView vs ListView.
✗ Incorrect
SingleChildScrollView builds all its children at once, which uses a lot of memory and slows down the app for very long lists. ListView builds items lazily.