Is it possible to use ListView.builder inside of CustomScrollView?
You can use List.generate as example below
return Scaffold(
body: CustomScrollView(
slivers: [
SliverAppBar(...),
SliverList(delegate: SliverChildListDelegate(
List.generate(yourList.length, (idx) {
return Padding(
padding: const EdgeInsets.only(left: 8.0, right: 8.0),
child: Card(
child: ListTile(
leading: Icon(null),
title: Text(yourList[idx]),
onTap: null,
),
),
);
})
))
],
),
);
The delegate
argument of SliverList
is not necessarily a SliverChildListDelegate
.
You can also use SliverChildBuilderDelegate
to achieve the builder
effect of ListView.builder
SliverList(delegate: SliverChildBuilderDelegate((context, index) {
return Container();
}));
I'm not sure how it is done in CustomScrollView but you can try this:
Scaffold(
body: NestedScrollView(
headerSliverBuilder: (BuildContext context, bool innerBoxIsScrolled) {
return <Widget>[
SliverAppBar(...),
];
},
body: ListView.builder(..),)
);