正如标题所说,在 Flutter 中使用 Stacks 时,如果“最后”渲染的孩子与所有其他孩子重叠,则只能与该孩子进行交互。在我的应用程序中,我有一个 ListWheelScrollView,它包含在一个堆栈中,然后使用位于 ScrollView 顶部的渐变进行“样式化”。
当给出一个例子时,这更有意义。
在几乎这种确切情况下存在一个现有问题:Flutter-GestureDetector not working with containers in stack
但是,它假定您正在使用手势检测器。
Stack(children: <Widget>[
Container(
height: 250,
child: Row(
mainAxisAlignment: MainAxisAlignment.center,
children: <Widget>[
Container(
width: _style.fontSize * 1.5,
child: ListWheelScrollView.useDelegate(
controller: fixedExtentScrollController,
physics: FixedExtentScrollPhysics(),
itemExtent: _style.fontSize * 1.5,
childDelegate: ListWheelChildLoopingListDelegate(
children: hours
.map((hour) => hour < 10
? Text(
"0$hour",
style: _style,
)
: Text(
"$hour",
style: _style,
))
.toList())),
),
Column(
mainAxisAlignment: MainAxisAlignment.center,
children: <Widget>[
Text(
":",
style: _style,
),
SizedBox(
height: 25, …Run Code Online (Sandbox Code Playgroud)