0
0
Fluttermobile~20 mins

Slivers (SliverList, SliverGrid, SliverAppBar) in Flutter - Practice Problems & Coding Challenges

Choose your learning style9 modes available
Challenge - 5 Problems
🎖️
Sliver Master
Get all challenges correct to earn this badge!
Test your skills under time pressure!
ui_behavior
intermediate
2: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'),
  ),
)
AThe app bar stays visible at the top and shrinks to toolbar height when scrolling up.
BThe app bar scrolls out of view completely when scrolling up.
CThe app bar expands and covers the list items when scrolling up.
DThe app bar disappears and reappears randomly when scrolling.
Attempts:
2 left
💡 Hint
Pinned means the app bar stays visible at the top when scrolling.
📝 Syntax
intermediate
2: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,
  ),
)
ASliverList(delegate: SliverChildListDelegate(List.generate(5, (index) => Text('Item $index'))))
BSliverList(delegate: SliverChildBuilderDelegate((context, index) => Text('Item $index'), childCount: 5))
CSliverList(delegate: SliverChildBuilderDelegate((context, index) => Text('Item ' + index.toString()), childCount: 5))
DSliverList(children: List.generate(5, (index) => Text('Item $index')))
Attempts:
2 left
💡 Hint
SliverList requires a delegate, not a children property.
ui_behavior
advanced
2: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),
    ),
  ],
)
AThe app bar scrolls away and grid items overlap it.
BThe app bar stays fixed at the top and grid scrolls under it.
CThe app bar never appears and the grid fills the screen.
DThe app bar appears when you scroll up slightly and hides when scrolling down, grid scrolls normally.
Attempts:
2 left
💡 Hint
Floating app bars appear when you scroll up a little.
lifecycle
advanced
2: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?
AThe app bar snaps open fully immediately after scroll ends.
BThe app bar stays collapsed and does not snap open.
CThe app bar disappears permanently until the next scroll.
DThe app bar flickers between open and closed states repeatedly.
Attempts:
2 left
💡 Hint
Snap makes the app bar open fully after a scroll ends if floating is true.
🔧 Debug
expert
2: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),
)
AchildCount must be greater than 10 for SliverGrid.
BContainer color cannot be Colors.red inside SliverGrid.
CcrossAxisCount cannot be zero; it must be at least 1.
DSliverChildBuilderDelegate requires a key parameter.
Attempts:
2 left
💡 Hint
Check the gridDelegate parameters carefully.