我想在ListView中使用OverflowBox,但它在可滚动内容的情况下无法正常工作,但在这些情况下它可以完美工作:
1.如果我用不可滚动的小部件(如Column)替换ListView。
1.如果ListView内容不需要滚动。
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条答案
按热度按时间tzdcorbm1#
将溢流盒放入固定大小的容器中。
krcsximq2#
如果你想保持HorizontalList滚动,你应该像这样使用shrinkWrap,假设HorizontalList是一个ListView:
将itemCount更改为try。
对于测试,我将所有内容放在一个列中,看起来像这样: