flutter - 使堆栈背景中的 ListView 可滚动
问题描述
我有一个 Stack,它的最底部有一些容器和水平 listView。(有意地,它是设计的一部分)。现在我试图滚动浏览它,它不起作用,因为顶部容器使它无法访问。如何保持相同的小部件树但使底部 listView 可滚动?
return Stack(
children: <Widget>[
AnimatedBuilder(
animation: ctrl,
builder: (context, child){
var pos = ctrl.position.pixels;
return Container(
height: pos<h?(pos/h * 250):250,
child: ListView.builder(
scrollDirection: Axis.horizontal,
itemBuilder: (ctxt, index){
return Container(
height: pos<h?(pos/h * 250):250,
width: 250,
child: Image(), //Horizontal listview
);
},
),
);
},
),
ListView(
controller: ctrl,
children: <Widget>[
AnimatedBuilder(
animation: ctrl,
builder: (context, child){
var pos = ctrl.position.pixels;
return Container(
height: pos<h?(pos/h * 250):250,
);
},
),
//This is the container I'm talking about, it's just like padding(It's nothing in there)
],
),
],
);
解决方案
您可以将ListView
后面的Container
顺序放在 里面Stack
,这样它就会结束Container
并且您可以与它进行交互。
或者您可以将 with 包裹Container
起来IgnorePointer
,这样手势就不会被 拦截,Container
您可以与 . 进行交互ListView
。
推荐阅读
- c - 只要它们包含“下一个”字段,是否可以在 C 中为不同的列表结构编写通用遍历函数?
- python - 我的 Discord 机器人不断出现错误,无法弄清楚如何修复它
- python - 将列值转换为 pyspark 数据框中的列
- android - gradle build:任务':app:validateSigningAutomationRelease'执行失败
- amazon-web-services - 如何使用 AWS CLI 使用 EC2 标签或名称删除 EC2 实例
- html - 使用jsp和java无法同时将多个文件上传到mysql数据库
- c# - 无法在对讲机中创建公司
- google-apps-script - 我无法从任何文件夹访问 createFile 方法。我想从 URL 将图像文件保存在 gdrive 中
- reactjs - 如何故意将 Web 服务器配置为返回 500
- node.js - renderer() 组件中的状态未更新