Reputation: 61
How can I build two lists to be displayed vertically so as one list of item is built and then the second follows in that vertical order.
Upvotes: 6
Views: 4082
Reputation: 10875
You can achieve this by using CustomScrollView with SliverList.
Your solution would look something like this:
CustomScrollView(
slivers: <Widget>[
//list 1 (using builder)
SliverList(
delegate: SliverChildBuilderDelegate(
(context, i) {
return ListTile(...); // HERE goes your list item
},
childCount: 3,
),
),
//list 2 (using list of widgets)
SliverList(
delegate: SliverChildListDelegate([
ListTile(..),
ListTile(..), //HERE goes your list item
]),
),
],
),
this will build one list after another as you scroll down. in the example above i have used both types of delegates available to build list.
ListView.builder()
ListView(children: ...)
Upvotes: 13