A Sliver is a special scrollable area that can change size and shape as you scroll. It helps create custom scroll effects like collapsing headers or grids inside a scroll view.
Click to reveal answer
beginner
What does SliverList do?
SliverList displays a scrollable list of widgets arranged linearly. It works inside a CustomScrollView to create flexible scrolling lists.
Click to reveal answer
beginner
How is SliverGrid different from SliverList?
SliverGrid shows widgets in a grid layout inside a scrollable area, while SliverList shows them in a single column list.
Click to reveal answer
intermediate
What is the purpose of SliverAppBar?
SliverAppBar is a scrollable app bar that can expand, collapse, and float as you scroll. It creates dynamic headers that react to scrolling.
Click to reveal answer
intermediate
Why use CustomScrollView with slivers?
CustomScrollView lets you combine multiple slivers like SliverAppBar, SliverList, and SliverGrid to build complex scrolling layouts with smooth animations.
Click to reveal answer
Which widget allows you to create a scrollable list inside a CustomScrollView?
AListView
BSliverGrid
CSliverAppBar
DSliverList
✗ Incorrect
SliverList is designed to create scrollable lists inside a CustomScrollView.
What does SliverAppBar do when you scroll up?
AIt stays fixed and never changes
BIt expands and floats
CIt collapses or shrinks
DIt turns into a grid
✗ Incorrect
SliverAppBar collapses or shrinks as you scroll up, creating a dynamic header effect.
Which sliver widget would you use to display items in a grid layout?
ASliverList
BSliverGrid
CSliverAppBar
DGridView
✗ Incorrect
SliverGrid arranges items in a grid inside a scrollable sliver.
What is the main advantage of using slivers in Flutter?
AThey allow flexible and custom scroll effects
BThey make apps run faster
CThey replace all other widgets
DThey automatically create buttons
✗ Incorrect
Slivers let you create flexible and custom scroll effects like collapsing headers and grids.
Which widget do you combine with slivers to build a scrollable area?
ACustomScrollView
BListView
CColumn
DStack
✗ Incorrect
CustomScrollView is used to combine multiple slivers into one scrollable area.
Explain how SliverAppBar enhances the user experience in a scrolling app.
Think about how the app bar changes when you scroll.
You got /4 concepts.
Describe the difference between SliverList and SliverGrid and when you might use each.
Consider how items are arranged visually.
You got /4 concepts.
Practice
(1/5)
1. What is the main purpose of using SliverAppBar in a Flutter app?
easy
A. To replace the default app bar with a static title
B. To display a fixed footer at the bottom of the screen
C. To create a grid layout inside a scrollable area
D. To create a header that can expand, collapse, and stay visible when scrolling
Solution
Step 1: Understand SliverAppBar role
SliverAppBar is designed to create headers that can expand and collapse as the user scrolls.
Step 2: Compare options with SliverAppBar behavior
Only To create a header that can expand, collapse, and stay visible when scrolling describes the expandable and pinned header behavior of SliverAppBar.
Final Answer:
To create a header that can expand, collapse, and stay visible when scrolling -> Option D
2. Which of the following is the correct way to create a SliverList inside a CustomScrollView?
easy
A. SliverList(items: List.generate(5, (index) => Text('Item $index')))
B. SliverList(delegate: SliverChildBuilderDelegate((context, index) => Text('Item $index')))
C. SliverList(itemBuilder: (context, index) => Text('Item $index'))
D. SliverList(children: [Text('Item 1'), Text('Item 2')])
Solution
Step 1: Recall SliverList constructor
SliverList requires a delegate parameter, usually SliverChildBuilderDelegate or SliverChildListDelegate.
Step 2: Check each option's syntax
SliverList(delegate: SliverChildBuilderDelegate((context, index) => Text('Item $index'))) correctly uses delegate: SliverChildBuilderDelegate. Options A, B, and C use invalid parameters or properties.
Final Answer:
SliverList(delegate: SliverChildBuilderDelegate((context, index) => Text('Item $index'))) -> Option B
B. SliverGridDelegateWithFixedCrossAxisCount is not a valid class
C. SliverGrid requires a delegate, not a children parameter
D. CustomScrollView cannot contain SliverGrid
Solution
Step 1: Check SliverGrid constructor requirements
SliverGrid requires a delegate parameter, not children.
Step 2: Validate other parts
SliverGridDelegateWithFixedCrossAxisCount is valid, and List.generate can be used inside a delegate.
Final Answer:
SliverGrid requires a delegate, not a children parameter -> Option C
Quick Check:
SliverGrid needs delegate, not children [OK]
Hint: SliverGrid uses delegate, not children, for lazy loading [OK]
Common Mistakes:
Using children instead of delegate in SliverGrid
Confusing SliverGridDelegateWithFixedCrossAxisCount as invalid
Thinking CustomScrollView disallows SliverGrid
5. You want to create a scrollable screen with a header that expands and pins, followed by a grid of images with 3 columns, and then a list of text items. Which of the following is the best way to structure your Flutter widget tree?