Challenge - 5 Problems
Sliver Master
Get all challenges correct to earn this badge!
Test your skills under time pressure!
❓ ui_behavior
intermediate2:00remaining
What is the visible effect of this SliverAppBar configuration?
Consider a SliverAppBar with
pinned: true and expandedHeight: 200. What happens when you scroll up the list?Flutter
SliverAppBar( pinned: true, expandedHeight: 200, flexibleSpace: FlexibleSpaceBar( title: Text('Demo'), ), )
Attempts:
2 left
💡 Hint
Pinned means the app bar stays visible at the top when scrolling.
✗ Incorrect
With pinned: true, the SliverAppBar remains visible and shrinks to the toolbar height as you scroll up, providing a persistent header.
📝 Syntax
intermediate2:00remaining
Which option correctly creates a SliverList with 5 Text widgets?
You want to create a SliverList that shows 5 items labeled 'Item 0' to 'Item 4'. Which code snippet is correct?
Flutter
SliverList(
delegate: SliverChildBuilderDelegate(
(context, index) => Text('Item $index'),
childCount: 5,
),
)Attempts:
2 left
💡 Hint
SliverList requires a delegate, not a children property.
✗ Incorrect
SliverList uses a delegate property. SliverChildBuilderDelegate takes an item builder and childCount. Option B uses correct syntax.
❓ ui_behavior
advanced2:00remaining
What happens when you combine SliverGrid with SliverAppBar in a CustomScrollView?
You have a CustomScrollView with a SliverAppBar (floating: true) and a SliverGrid below it. What is the scrolling behavior?
Flutter
CustomScrollView(
slivers: [
SliverAppBar(
floating: true,
expandedHeight: 150,
flexibleSpace: FlexibleSpaceBar(title: Text('Grid Demo')),
),
SliverGrid(
delegate: SliverChildBuilderDelegate(
(context, index) => Container(color: Colors.blue, child: Center(child: Text('$index'))),
childCount: 20,
),
gridDelegate: SliverGridDelegateWithFixedCrossAxisCount(crossAxisCount: 3),
),
],
)Attempts:
2 left
💡 Hint
Floating app bars appear when you scroll up a little.
✗ Incorrect
With floating: true, the SliverAppBar shows when you scroll up slightly and hides on scroll down. The SliverGrid scrolls normally below it.
❓ lifecycle
advanced2:00remaining
Which statement about SliverAppBar lifecycle is true when using snap: true and floating: true?
What happens to the SliverAppBar when you quickly scroll down and release the scroll in a CustomScrollView with snap and floating enabled?
Attempts:
2 left
💡 Hint
Snap makes the app bar open fully after a scroll ends if floating is true.
✗ Incorrect
With snap: true and floating: true, the app bar snaps open fully when the user stops scrolling after a quick scroll down.
🔧 Debug
expert2:00remaining
Why does this SliverGrid code cause a runtime error?
Examine this SliverGrid code snippet. It throws an error at runtime. What is the cause?
Flutter
SliverGrid(
delegate: SliverChildBuilderDelegate(
(context, index) => Container(color: Colors.red),
childCount: 10,
),
gridDelegate: SliverGridDelegateWithFixedCrossAxisCount(crossAxisCount: 0),
)Attempts:
2 left
💡 Hint
Check the gridDelegate parameters carefully.
✗ Incorrect
crossAxisCount defines how many columns the grid has. Zero columns is invalid and causes a runtime error.