Complete the code to create a CustomScrollView with a single SliverList.
CustomScrollView(
slivers: [
SliverList(
delegate: SliverChildBuilderDelegate(
(context, index) => Text('Item $index'),
childCount: [1],
),
),
],
)The childCount property expects an integer to define how many items to build. Here, 10 means 10 items will be shown.
Complete the code to add a SliverAppBar inside CustomScrollView.
CustomScrollView(
slivers: [
[1](
title: Text('My AppBar'),
floating: true,
),
],
)AppBar directly inside slivers.SliverList instead of SliverAppBar.The SliverAppBar widget is used inside a CustomScrollView to create an app bar that scrolls with the content.
Fix the error in the code by completing the blank with the correct widget to create a grid inside CustomScrollView.
CustomScrollView(
slivers: [
[1](
gridDelegate: SliverGridDelegateWithFixedCrossAxisCount(crossAxisCount: 2),
delegate: SliverChildBuilderDelegate(
(context, index) => Container(color: Colors.blue, height: 100),
childCount: 6,
),
),
],
)GridView inside slivers causes errors.SliverList instead of SliverGrid for grids.The SliverGrid widget is used to create grid layouts inside a CustomScrollView. GridView cannot be used directly inside slivers.
Fill both blanks to create a CustomScrollView with a SliverAppBar and a SliverList.
CustomScrollView(
slivers: [
[1](
title: Text('Header'),
pinned: true,
),
[2](
delegate: SliverChildListDelegate([
ListTile(title: Text('Item 1')),
ListTile(title: Text('Item 2')),
]),
),
],
)SliverGrid instead of SliverList for the list.The first blank should be SliverAppBar to create the header bar. The second blank should be SliverList to create a list of items.
Fill all three blanks to build a CustomScrollView with a pinned SliverAppBar, a SliverGrid, and a SliverList.
CustomScrollView(
slivers: [
[1](
title: Text('Gallery'),
pinned: true,
),
[2](
gridDelegate: SliverGridDelegateWithFixedCrossAxisCount(crossAxisCount: 3),
delegate: SliverChildBuilderDelegate(
(context, index) => Container(color: Colors.red, height: 100),
childCount: 9,
),
),
[3](
delegate: SliverChildListDelegate([
ListTile(title: Text('Footer Item 1')),
ListTile(title: Text('Footer Item 2')),
]),
),
],
)SliverChildBuilderDelegate as a sliver widget.SliverGrid and SliverList positions.The first blank is SliverAppBar for the pinned header. The second blank is SliverGrid to show a grid of items. The third blank is SliverList for the footer list.