A CustomScrollView is a scrollable widget that lets you create custom scroll effects by combining multiple scrollable elements called slivers.
Click to reveal answer
beginner
What is a sliver in the context of CustomScrollView?
A sliver is a portion of a scrollable area that can have custom behavior or layout, like a list, grid, or app bar that reacts to scrolling.
Click to reveal answer
beginner
Name two common slivers used inside a CustomScrollView.
Two common slivers are SliverAppBar (a scrollable app bar) and SliverList (a scrollable list of items).
Click to reveal answer
intermediate
How does CustomScrollView improve UI design compared to a regular ListView?
CustomScrollView allows combining different scrollable elements with custom effects, like collapsing headers or mixed lists and grids, which ListView alone cannot do.
Click to reveal answer
beginner
What property do you use to add slivers inside a CustomScrollView?
You use the slivers property, which takes a list of sliver widgets to build the scrollable content.
Click to reveal answer
Which widget is used to create a scrollable area with custom scroll effects in Flutter?
ACustomScrollView
BListView
CGridView
DSingleChildScrollView
✗ Incorrect
CustomScrollView allows combining multiple slivers for custom scroll effects.
What does a sliver represent inside a CustomScrollView?
AA scrollable portion with custom layout or behavior
BA button widget
CA fixed header
DA background image
✗ Incorrect
Slivers are scrollable parts that can have special layouts or behaviors.
Which sliver widget provides a scrollable app bar that can expand or collapse?
ASliverList
BSliverGrid
CSliverAppBar
DSliverFillRemaining
✗ Incorrect
SliverAppBar is used for scrollable app bars.
How do you add multiple slivers inside a CustomScrollView?
AUsing the children property
BUsing the slivers property
CUsing the items property
DUsing the widgets property
✗ Incorrect
The slivers property takes a list of sliver widgets.
Which of these is NOT a sliver widget?
ASliverList
BSliverGrid
CSliverAppBar
DListView
✗ Incorrect
ListView is a scrollable widget but not a sliver.
Explain what a CustomScrollView is and why you might use it in a Flutter app.
Think about combining different scrollable parts with special effects.
You got /3 concepts.
Describe how you would build a screen with a collapsing app bar and a scrollable list using CustomScrollView.
Focus on which slivers to use and how they work together.
You got /4 concepts.
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
Step 1: Understand the role of CustomScrollView
CustomScrollView allows combining different scrollable widgets called slivers into one scrollable area.
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.
Final Answer:
To combine multiple scrollable widgets called slivers into one scrollable area. -> Option A
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
Step 1: Check CustomScrollView property for slivers
CustomScrollView uses the slivers property to accept sliver widgets, not children.
Step 2: Identify correct sliver list syntax
SliverList requires a delegate like SliverChildBuilderDelegate to build items lazily.
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
Step 1: Check CustomScrollView properties
CustomScrollView expects sliver widgets inside the slivers property, not children.
Step 2: Verify other parts
SliverChildBuilderDelegate has childCount, SliverList is valid, and Text is allowed inside delegate.
Final Answer:
Using children instead of slivers property in CustomScrollView. -> Option C
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
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.
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.
Final Answer:
SliverAppBar (with flexibleSpace), SliverGrid, SliverList -> Option A