body: new ListView(children: <Widget>[_homeWidget()]),
Widget _homeWidget() {
return new Container(
height: MediaQuery.of(context).size.height,
child: new Column(
children: <Widget>[
new Container(
height: 180.0,
child: new Container(
child: advertisementList.length != 0
? _imageSlider()
: new Container(),
)),
new Container(
height: 200.0,
child: new GridView.extent(
primary: false,
maxCrossAxisExtent: 150.0,
children: _buildGrideTiles(12),
))
],
),
);
}
为什么要禁用网格视图中的滚动? 由行和列组成的小部件可以满足您的要求。
不,我有一个列表,我需要禁用网格滚动。
我在android中使用带有recyclerview的nestedscrollvierw,它有一个属性nestedsroll = false;
我想用禁用子视图滚动来做嵌套滚动。
在子小部件上设置主要属性会删除嵌套滚动。 测试代码
ListView(
shrinkWrap: true,
children: <Widget>[
Text("List Item"),
Text("List Item"),
GridView.count(
shrinkWrap: true,
primary: true,
padding: const EdgeInsets.all(20.0),
crossAxisSpacing: 10.0,
crossAxisCount: 2,
children: <Widget>[
const Text('He\'d have you all unravel at the'),
const Text('Heed not the rabble'),
const Text('Sound of screams but the'),
const Text('Who scream'),
const Text('Revolution is coming...'),
const Text('Revolution, they...'),
],
),
Text("List Item"),
Text("List Item"),
Text("List Item"),
Text("List Item"),
Text("List Item"),
Text("List Item"),
Text("List Item"),
Text("List Item"),
],
);
主要输出为真: https ://www.youtube.com/watch?v=8iCf6mwOL2U
主要错误的输出: https ://www.youtube.com/watch?v=IXFvRVaD8TI&
太感谢了。
但我用我的逻辑解决了这个问题。
我创建了小部件列表。
但它需要很长的过程。
再次感谢。
@vithanichandresh这个问题可以结束还是还有悬而未决的问题?
我遇到了同样的问题。
另一种解决方案是将 GridView 包装在 IgnorePointer 小部件中。
如果没有其他信息,很遗憾,我们不确定如何解决此问题。 因此,我们现在不情愿地关闭这个错误。 如果您对我们有更多信息,请随时评论该错误; 我们将立即重新开放!
感谢您的贡献。
抄送@Hixie
如果您只想完全禁用滚动,可以使用physics: new NeverScrollableScrollPhysics()
。
@Hixie那么,当父列表到达gridview底部时如何处理分页事件?
我不明白这个问题。 我建议在 Stack Overflow 或 flutter-dev 上发布您想要达到的效果的清晰描述。
物理学:新的 NeverScrollableScrollPhysics()
哇。 谢谢💯
我遇到了同样的问题。
另一种解决方案是将 GridView 包装在 IgnorePointer 小部件中。
谢谢
如果您只想完全禁用滚动,可以使用
physics: new NeverScrollableScrollPhysics()
。
在我读到这篇文章之前,我正要彻底失望。 多好的一天啊 :)
有一个Table.count(children: [...])
样式的小部件不会滚动或尝试扩展到高度会很好
在子小部件上设置主要属性会删除嵌套滚动。 测试代码
ListView( shrinkWrap: true, children: <Widget>[ Text("List Item"), Text("List Item"), GridView.count( shrinkWrap: true, primary: true, padding: const EdgeInsets.all(20.0), crossAxisSpacing: 10.0, crossAxisCount: 2, children: <Widget>[ const Text('He\'d have you all unravel at the'), const Text('Heed not the rabble'), const Text('Sound of screams but the'), const Text('Who scream'), const Text('Revolution is coming...'), const Text('Revolution, they...'), ], ), Text("List Item"), Text("List Item"), Text("List Item"), Text("List Item"), Text("List Item"), Text("List Item"), Text("List Item"), Text("List Item"), ], );
主要输出为真: https ://www.youtube.com/watch?v=8iCf6mwOL2U
主要错误的输出: https ://www.youtube.com/watch?v=IXFvRVaD8TI&
为什么这不适用于 ScrollSingleView。
GridView.count(
physics: NeverScrollableScrollPhysics(),
)
如果您只想完全禁用滚动,可以使用
physics: new NeverScrollableScrollPhysics()
。
男人!! 说真的,这有效
我在 Listview 下使用 Gridview.count
如果您只想完全禁用滚动,可以使用
physics: new NeverScrollableScrollPhysics()
。
谢谢你。 我永远不会猜到他们会有永远不可滚动的 scrollPhysics
GridView.count(physics: NeverScrollableScrollPhysics(),)
如果您只想完全禁用滚动,可以使用
physics: new NeverScrollableScrollPhysics()
。
如果网格有大约 100 个项目,则不会重绘网格视图本身。 我遇到了这个问题,并且仍在尝试找到解决此问题的方法。
最有用的评论
如果您只想完全禁用滚动,可以使用
physics: new NeverScrollableScrollPhysics()
。