Reputation: 172
I'm currently trying to create a sliverlist that gets a list of user UID's from firebase then uses the streambuilder to find the information for each user. The problem is that is creates a bunch of sliverlists with a streambuilder listview inside so I have a bunch of items that are part of their own individual lists. How can I make this more efficiently to only build one sliverlist with all the item?
return SliverList(
delegate: SliverChildBuilderDelegate(
(context, index) {
return StreamBuilder(
stream: userSearch(context, snapshot.data['members'][index]),
builder: (context, snapshot) {
return ListView.separated(
shrinkWrap: true,
padding: const EdgeInsets.all(8),
itemCount: snapshot.data.length,
itemBuilder: (BuildContext context, int index) {
return userWidget(
context,
snapshot.data[index],
);
},
separatorBuilder: (BuildContext context, int index) =>
const Divider(),
);
},
);
},
childCount: snapshot.data['members'].length,
),
);
Upvotes: 0
Views: 244
Reputation: 7716
You can add NeverScrollableScrollPhysics() as the ScrollPhysics
for the inner ListView
.
It makes the ListView
not scroll which means only the SliverList
can scroll the items.
return ListView.separated(
physics: NeverScrollableScrollPhysics(), //Add this line
...
);
Upvotes: 1