This happens when ListView has no constrained height which makes it gets an infinite height, you can solve this using two solutions
-
add
shrinkWrap: true
as a parameter
which will tell the ListView to use a little space as possible, -
Wrap your ListView with a constrained height widget, such as a
SizedBox
or aContainer
, and give it a height and width like so
Container(
height: 50,
width: 50,
child: ListView()
)
hope this solves your problem