I have a ListView in a CustomScrollView widget that should display some text but the problem is that it does not display anything.
if i remove the CustomScrollView widget, the problem will be solved!
But i need to use CustomScrollView
What is the problem?
CustomScrollView(
slivers: [
SliverToBoxAdapter(
child: Expanded(
child: ListView.builder(
itemBuilder: (context, index) {
return Text("${index}");
},
itemCount: 5,
),
),
)
],
),
3
Answers
Try to give listview properties
shrinkWrap: true
and try with expanded or without expandedYou could use CustomScrollView slightly differently to achieve that:
You should use
SliverList
insideCustomScrollView
.Find more about
CustomScrollView