Bird
Raised Fist0
Fluttermobile~20 mins

CustomScrollView in Flutter - Practice Problems & Coding Challenges

Choose your learning style10 modes available
Challenge - 5 Problems
🎖️
CustomScrollView Master
Get all challenges correct to earn this badge!
Test your skills under time pressure!
❓ ui_behavior
intermediate
2: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,
      ),
    ),
  ],
)
AA scrollable list with a pinned app bar titled 'Hello' that stays visible on top while scrolling through 3 list items.
BA static app bar with title 'Hello' and a non-scrollable list of 3 items below it.
CAn error because SliverAppBar cannot be used inside CustomScrollView.
DA scrollable list with no app bar visible and 3 list items.
Attempts:
2 left
💡 Hint
Remember that SliverAppBar with pinned:true stays visible when scrolling.
❓ lifecycle
intermediate
2: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')))),
    ),
  ],
)
AThe app bar expands and collapses smoothly without snapping.
BThe app bar stays hidden until the user scrolls to the top of the list.
CThe app bar immediately snaps open and becomes fully visible when the user scrolls up slightly.
DThe app bar disappears permanently after scrolling.
Attempts:
2 left
💡 Hint
Floating and snap together cause the app bar to appear quickly on scroll up.
📝 Syntax
advanced
2: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.
ACustomScrollView(children: [SliverGrid(delegate: SliverChildBuilderDelegate((context, index) => Text('Item $index'), childCount: 4), gridDelegate: SliverGridDelegateWithFixedCrossAxisCount(crossAxisCount: 2))])
BCustomScrollView(slivers: [SliverGrid(delegate: SliverChildBuilderDelegate((context, index) => Text('Item $index'), childCount: 4), gridDelegate: SliverGridDelegateWithFixedCrossAxisCount(crossAxisCount: 2))])
CCustomScrollView(slivers: [SliverGrid(delegate: SliverChildListDelegate([Text('Item 0'), Text('Item 1'), Text('Item 2'), Text('Item 3')]), gridDelegate: SliverGridDelegateWithFixedCrossAxisCount(crossAxisCount: 2))])
DCustomScrollView(slivers: [SliverGrid(delegate: SliverChildBuilderDelegate((context, index) => Text('Item $index')), gridDelegate: SliverGridDelegateWithFixedCrossAxisCount(crossAxisCount: 4))])
Attempts:
2 left
💡 Hint
CustomScrollView uses the slivers parameter, not children.
🔧 Debug
advanced
2: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),
  ],
)
AA Container widget cannot be a direct child of slivers; only sliver widgets are allowed.
BCustomScrollView requires a ScrollController to be set explicitly.
CSliverList must be the last sliver in the list.
DSliverChildBuilderDelegate requires a childCount of zero or null to work properly.
Attempts:
2 left
💡 Hint
Check what types of widgets are allowed inside the slivers list.
🧠 Conceptual
expert
2: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,
      ),
    ),
  ],
)
A4 items
B10 items
C6 items
D5 items
Attempts:
2 left
💡 Hint
Divide screen height by itemExtent to find visible items count.

Practice

(1/5)
1. What is the main purpose of a CustomScrollView in Flutter?
easy
A. To combine multiple scrollable widgets called slivers into one scrollable area.
B. To create a fixed header without scrolling.
C. To display only a single scrollable list.
D. To handle user input events like taps and swipes.

Solution

  1. Step 1: Understand the role of CustomScrollView

    CustomScrollView allows combining different scrollable widgets called slivers into one scrollable area.
  2. Step 2: Compare options with this understanding

    Only To combine multiple scrollable widgets called slivers into one scrollable area. correctly describes this purpose; others describe unrelated features.
  3. Final Answer:

    To combine multiple scrollable widgets called slivers into one scrollable area. -> Option A
  4. Quick Check:

    CustomScrollView = combine slivers [OK]
Hint: Remember: CustomScrollView = multiple slivers scrolling together [OK]
Common Mistakes:
  • Thinking CustomScrollView only shows one list
  • Confusing CustomScrollView with fixed headers
  • Assuming it handles input events directly
2. Which of the following is the correct way to start a CustomScrollView with a sliver list in Flutter?
easy
A. CustomScrollView(children: [SliverList(delegate: SliverChildBuilderDelegate((context, index) => Text('Item $index'), childCount: 10))])
B. CustomScrollView(slivers: [SliverList(delegate: SliverChildBuilderDelegate((context, index) => Text('Item $index'), childCount: 10))])
C. CustomScrollView(children: [ListView.builder(itemCount: 10, itemBuilder: (context, index) => Text('Item $index'))])
D. CustomScrollView(slivers: [ListView.builder(itemCount: 10, itemBuilder: (context, index) => Text('Item $index'))])

Solution

  1. Step 1: Check CustomScrollView property for slivers

    CustomScrollView uses the slivers property to accept sliver widgets, not children.
  2. Step 2: Identify correct sliver list syntax

    SliverList requires a delegate like SliverChildBuilderDelegate to build items lazily.
  3. Final Answer:

    CustomScrollView(slivers: [SliverList(delegate: SliverChildBuilderDelegate((context, index) => Text('Item $index'), childCount: 10))]) -> Option B
  4. Quick Check:

    Use slivers property with SliverList [OK]
Hint: Use slivers: [] property, not children: [] for CustomScrollView [OK]
Common Mistakes:
  • Using children instead of slivers property
  • Putting ListView inside CustomScrollView slivers
  • Not using SliverChildBuilderDelegate for SliverList
3. What will be the visible output when running this Flutter code snippet?
CustomScrollView(
  slivers: [
    SliverAppBar(
      expandedHeight: 100,
      flexibleSpace: FlexibleSpaceBar(title: Text('Header')),
      pinned: true,
    ),
    SliverList(
      delegate: SliverChildListDelegate([
        Container(height: 50, color: Colors.red),
        Container(height: 50, color: Colors.green),
        Container(height: 50, color: Colors.blue),
      ]),
    ),
  ],
)
medium
A. An error because SliverAppBar cannot be used inside CustomScrollView.
B. A static screen with only the header 'Header' visible and no scrolling.
C. A scrollable screen with three colored boxes but no header visible.
D. A scrollable screen with a pinned header titled 'Header' and three colored boxes stacked vertically.

Solution

  1. Step 1: Understand SliverAppBar behavior

    SliverAppBar with pinned: true stays visible at top when scrolling.
  2. Step 2: Analyze SliverList content

    SliverList shows three containers stacked vertically with specified colors and heights.
  3. Final Answer:

    A scrollable screen with a pinned header titled 'Header' and three colored boxes stacked vertically. -> Option D
  4. Quick Check:

    SliverAppBar pinned + SliverList visible = A scrollable screen with a pinned header titled 'Header' and three colored boxes stacked vertically. [OK]
Hint: Pinned SliverAppBar stays visible while scrolling content below [OK]
Common Mistakes:
  • Thinking header disappears on scroll
  • Assuming no scrolling because of pinned header
  • Believing SliverAppBar causes error inside CustomScrollView
4. Identify the error in this Flutter code using CustomScrollView:
CustomScrollView(
  children: [
    SliverList(
      delegate: SliverChildBuilderDelegate(
        (context, index) => Text('Item $index'),
        childCount: 5,
      ),
    ),
  ],
)
medium
A. SliverList cannot be used inside CustomScrollView.
B. Missing itemCount in SliverChildBuilderDelegate.
C. Using children instead of slivers property in CustomScrollView.
D. Text widget cannot be used inside SliverChildBuilderDelegate.

Solution

  1. Step 1: Check CustomScrollView properties

    CustomScrollView expects sliver widgets inside the slivers property, not children.
  2. Step 2: Verify other parts

    SliverChildBuilderDelegate has childCount, SliverList is valid, and Text is allowed inside delegate.
  3. Final Answer:

    Using children instead of slivers property in CustomScrollView. -> Option C
  4. Quick Check:

    CustomScrollView uses slivers, not children [OK]
Hint: CustomScrollView needs slivers: [], not children: [] [OK]
Common Mistakes:
  • Using children property instead of slivers
  • Confusing SliverList with ListView
  • Thinking Text widget is invalid inside SliverChildBuilderDelegate
5. You want to create a scrollable screen with a header that shrinks on scroll, a grid of images, and a list of text items below. Which combination of slivers inside a CustomScrollView will achieve this?
hard
A. SliverAppBar (with flexibleSpace), SliverGrid, SliverList
B. SliverPersistentHeader, ListView, GridView
C. AppBar, GridView.builder, ListView.builder
D. SliverToBoxAdapter, SliverFixedExtentList, SliverFillRemaining

Solution

  1. Step 1: Identify slivers for header, grid, and list

    SliverAppBar with flexibleSpace creates a shrinking header. SliverGrid shows a grid of items. SliverList shows a scrollable list.
  2. Step 2: Check options for correct sliver usage

    SliverAppBar (with flexibleSpace), SliverGrid, SliverList uses all correct slivers inside CustomScrollView. Others mix non-sliver widgets or incorrect combinations.
  3. Final Answer:

    SliverAppBar (with flexibleSpace), SliverGrid, SliverList -> Option A
  4. Quick Check:

    Header + grid + list = SliverAppBar + SliverGrid + SliverList [OK]
Hint: Use SliverAppBar for header, SliverGrid for grid, SliverList for list [OK]
Common Mistakes:
  • Using ListView/GridView inside CustomScrollView slivers
  • Not using SliverAppBar for shrinking header
  • Confusing SliverPersistentHeader with SliverAppBar
Recommended

Ready to prove it?

Pass the test and this pattern moves unknown strong while earning +1 Grip toward your certificate.

10 questions~5 mineasy hard