Challenge - 5 Problems
CustomScrollView Master
Get all challenges correct to earn this badge!
Test your skills under time pressure!
❓ ui_behavior
intermediate2:00remaining
What is the visible output of this CustomScrollView code?
Consider this Flutter code snippet using
CustomScrollView. What will the user see on the screen?Flutter
CustomScrollView(
slivers: [
SliverAppBar(
expandedHeight: 150,
flexibleSpace: FlexibleSpaceBar(
title: Text('Hello'),
),
pinned: true,
),
SliverList(
delegate: SliverChildBuilderDelegate(
(context, index) => ListTile(title: Text('Item $index')),
childCount: 3,
),
),
],
)Attempts:
2 left
💡 Hint
Remember that SliverAppBar with pinned:true stays visible when scrolling.
✗ Incorrect
The SliverAppBar with pinned:true stays fixed at the top while the SliverList scrolls beneath it. The FlexibleSpaceBar shows the title 'Hello'.
❓ lifecycle
intermediate2:00remaining
What happens when you scroll up in this CustomScrollView?
Given this CustomScrollView with a SliverAppBar that has
floating: true and snap: true, what is the behavior when the user scrolls up slightly?Flutter
CustomScrollView(
slivers: [
SliverAppBar(
floating: true,
snap: true,
expandedHeight: 100,
flexibleSpace: FlexibleSpaceBar(title: Text('Snap AppBar')),
),
SliverList(
delegate: SliverChildListDelegate(List.generate(10, (i) => ListTile(title: Text('Item $i')))),
),
],
)Attempts:
2 left
💡 Hint
Floating and snap together cause the app bar to appear quickly on scroll up.
✗ Incorrect
With floating:true and snap:true, the app bar snaps fully open immediately when the user scrolls up even a little.
📝 Syntax
advanced2:30remaining
Which option correctly creates a CustomScrollView with a SliverGrid?
Select the code snippet that correctly builds a CustomScrollView containing a SliverGrid with 4 items arranged in 2 columns.
Attempts:
2 left
💡 Hint
CustomScrollView uses the slivers parameter, not children.
✗ Incorrect
Option B correctly uses slivers with SliverGrid, SliverChildBuilderDelegate with childCount 4, and gridDelegate with 2 columns.
🔧 Debug
advanced2:00remaining
Why does this CustomScrollView code cause a runtime error?
This code throws an error when run. What is the cause?
Flutter
CustomScrollView(
slivers: [
SliverList(
delegate: SliverChildBuilderDelegate(
(context, index) => ListTile(title: Text('Item $index')),
childCount: 5,
),
),
Container(height: 100, color: Colors.red),
],
)Attempts:
2 left
💡 Hint
Check what types of widgets are allowed inside the slivers list.
✗ Incorrect
CustomScrollView's slivers list only accepts sliver widgets. Container is not a sliver and causes a runtime error.
🧠 Conceptual
expert2:30remaining
How many items are visible initially in this CustomScrollView with SliverFixedExtentList?
Given this code, how many list items will be visible on the screen initially if the screen height is 600 pixels?
Flutter
CustomScrollView(
slivers: [
SliverFixedExtentList(
itemExtent: 120,
delegate: SliverChildBuilderDelegate(
(context, index) => ListTile(title: Text('Item $index')),
childCount: 10,
),
),
],
)Attempts:
2 left
💡 Hint
Divide screen height by itemExtent to find visible items count.
✗ Incorrect
Each item is 120 pixels tall. 600 / 120 = 5 items fit exactly on screen initially.