How can I solve the problem shown in the image below?
In the first case, the elements come to me with a certain height, then at another time the same elements come to me with a height less than the previous one, so an empty space remains at the bottom of the array!
How to avoid this case without using SingleChildScrollView or FittedBox?
The code:
SizedBox(
height: 500,
child: ListView.separated(
itemCount: 5,
scrollDirection: Axis.horizontal,
separatorBuilder: (context, index) => const SizedBox(width: 20),
itemBuilder: (context, index) => Container(),
),
),
I tried many ways and it didn’t work.
2
Answers
There is a method: Set fixed height for your Container (wrap ListView), then allows your listview item resizeable, eg.
You can replacing ListView.builder with SingleChildScrollView+Row
Example: Select item and drag Slider to change it height, the parent container will fitted.
(open https://dartpad.dev/ and paster this code and press Run.)