【发布时间】:2020-08-27 03:36:25
【问题描述】:
我在使用 PageView 构建的屏幕上有一个较小的元素,因为我需要对列表中的每个项目进行对齐效果。但这意味着边缘将是齐平的,没有视觉指示 PageView 元素是可滚动的。我尝试将 PageView 放在堆栈中,顶部有一个容器(如叠加层),该容器具有线性渐变以“遮蔽”侧面以使元素看起来圆润,但这会阻止滚动手势到达 PageView。
我的问题是:是否有一个我找不到的小部件允许滚动手势通过它,同时在视觉上出现在其他元素之上?我知道我可以在其上绘制小于 PageView 的元素,但我只是想知道其他人是否成功地完成了类似的操作。
编辑:这是工作代码的简化版本。我无法滑动到下一个页面视图。
return Scaffold(
body: Center(
child: Container(
padding: const EdgeInsets.all(35.0),
child: Stack(
children: [
PageView(
children: [
Container(color: Colors.blue[200]),
Container(color: Colors.red[200]),
Container(color: Colors.deepPurple[200])
]
),
Container(
decoration: BoxDecoration(
gradient: LinearGradient(
begin: Alignment.centerLeft,
end: Alignment.centerRight,
colors: [ Color.fromARGB(50, 0, 0, 0), Color.fromARGB(0, 0, 0, 0), Color.fromARGB(0, 0, 0, 0), Color.fromARGB(50, 0, 0, 0) ],
stops: [ 0.05, 0.25, 0.75, 0.95 ]
)
)
)
]
)
),
),
);
【问题讨论】:
-
这不应该发生只要没有输入期望小部件超过浏览量你应该很好去如果有那么你应该检查它的
hittestbehavior属性,请发布工作代码 -
@Yadu 该元素的树中没有任何其他手势检测器。