【发布时间】:2019-12-20 00:19:58
【问题描述】:
正如标题所说,在 Flutter 中使用 Stacks 时,如果该子项与所有其他子项重叠,则只有“最后”渲染的子项可以交互。在我的应用程序中,我有一个 ListWheelScrollView,它包含在 Stack 中,然后使用位于 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,
)
],
),
Container(
width: _style.fontSize * 1.5,
child: ListWheelScrollView.useDelegate(
physics: FixedExtentScrollPhysics(),
itemExtent: _style.fontSize * 1.5,
childDelegate: ListWheelChildLoopingListDelegate(
children: minutes
.map((minute) => minute < 10
? Text(
"0$minute",
style: _style,
)
: Text(
"$minute",
style: _style,
))
.toList())),
),
],
),
),
Container(
height: 250,
child: Column(
children: <Widget>[
Container(
height: 75.3,
decoration: BoxDecoration(
gradient: LinearGradient(
begin: Alignment.bottomCenter,
end: Alignment.topCenter,
colors: [
Colors.white.withOpacity(0.1),
Theme.of(context).scaffoldBackgroundColor
])),
),
Center(
child: Container(
height: 83.3,
width: 220,
decoration: BoxDecoration(
border: Border.all(
color: Color(0xFFc0ccd4), width: 5),
))),
],
),
)
]),
该设计按预期完美运行,但是我不再能够滚动,因为容器位于滚动小部件的顶部。
有什么解决方法吗?
【问题讨论】:
-
该小部件对我不起作用。它现在实际上阻塞了滚动小部件的整个区域。
标签: flutter dart flutter-layout