gpt4 book ai didi

flutter - 禁用 ListView 滚动

转载 作者:IT老高 更新时间:2023-10-28 12:44:22 32 4
gpt4 key购买 nike

如果页面没有超出屏幕大小,是否可以禁用 ListView 滚动?

我总是使用 ListView 来避免溢出屏幕,但是当页面的内容小于屏幕时,我可以看到结束滚动动画,在这种情况下如何禁用滚动,并且如果屏幕大小能够滚动小吗??

最佳答案

我认为最好的方法是使用 SingleChildScrollView :

This widget is useful when you have a single box that will normally be entirely visible, for example a clock face in a time picker, but you need to make sure it can be scrolled if the container gets too small in one axis (the scroll direction).

而不是使用 ListView 只需使用 Column 并将其放在 SingleChildScrollView 内:

    SingleChildScrollView(
child: Column(
mainAxisSize: MainAxisSize.min,
children: <Widget>[/**/],
),
)

或者如果你出于某种原因需要使用ListView,你可以使用shr​​inkWrapNeverScrollableScrollPhysics:

    SingleChildScrollView(
child: ListView(
shrinkWrap: true,
physics: NeverScrollableScrollPhysics(),
children: <Widget>[/**/],
),
)

关于flutter - 禁用 ListView 滚动,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/57246120/

32 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com