For a ListView, set shrinkWrap property to true
shrinkWrap: true
Why is this needed?
ListView always tries to fill all the available space given by the parent element.
So, let’s say that the parent is a Column, then, we know that the column takes the max height available, so if your list is longer then you’ll be having a problem, there isn’t enough space available. And if the list is smaller then it’ll try to fill the available space, even though it can’t.
With shrinkWrap: true
, you can change this behavior so that the ListView only occupies the space it needs (it will still scroll when there more items).