I want to use OverflowBox inside a ListView but it doesn’t work properly in case of scrollable content but it works perfectly in those cases:
- If I replace ListView with a non-scrollable widget such as Column.
- If the ListView content doesn’t need to be scrolled.
ListView(
children: [
SizedBox(
height: MediaQuery.of(context).size.height * .45,
child: OverflowBox(
maxHeight: MediaQuery.of(context).size.height * .45,
maxWidth: MediaQuery.of(context).size.width,
child: HorizontalList(images: data?.pictures ?? []),
),
),
],
)
2
Answers
Put the overflow box in a container with fixed size.
If you want to keep the HorizontalList scrolling, you should use shrinkWrap like this, assuming HorizontalList is a ListView:
Change the itemCount to try.
For Testing I’m putting all in a Column so looks like this: