TL;DR 我需要容器填充垂直空间,以便它可以作为触摸监听器。尝试了大多数解决方案,但似乎没有什么起作用的。
所以我想做的是让我的容器在保持固定宽度的同时填满垂直空间。 前两张是现在的情况,第三张是我想要的。我的想法是让容器透明,并具有手势触摸监听器。如果有更好的想法可以提出不同的解决方案。
Widget build(BuildContext context) {
return new GestureDetector(
onHorizontalDragUpdate: _move,
onHorizontalDragEnd: _handleDragEnd,
child: new Stack(
children: <Widget>[
new Positioned.fill(
child: new Row(
mainAxisAlignment: MainAxisAlignment.end,
children: <Widget>[
new Container(
child: new IconButton(
padding: new EdgeInsets.only(top: 16.0, bottom: 16.0, left: 24.0, right: 24.0),
icon: new Icon(Icons.warning),
color: Colors.black12,
onPressed: () {},
)
),
],
),
),
new SlideTransition(
position: new Tween<Offset>(
begin: Offset(0.0, 0.0),
end: const Offset(-0.6, 0.0),
).animate(_animation),
child: new Card(
child: new Row(
children: <Widget>[
new Container(
width: 20.0,
height: 20.0,
color: Colors.amber,
),
new Expanded(
child: new Column(
mainAxisSize: MainAxisSize.min,
children: <Widget>[
_getListTile(),
_ifStoplineIsToBeShown()
],
),
)
],
)
),
),
],
)
);
}
我相当确定自己错过了什么,因为我尝试了很多不同的方法,但好像没有什么起作用。
我还上传了一个带有调试信息的图像,在这里。
PS. 我知道我已将高度设置为固定值,但这是显示容器的唯一方法。
onHorizontalDragStart
没有被调用吗?你的“固定宽度”在哪里? - creativecreatorormaybenot