[英]Flutter PositionedTapDetector not working with stack widget
When using the code without the stack, the PositionedTapDetector input area was the container.当使用没有堆栈的代码时,PositionedTapDetector 输入区域是容器。 However, when I've added the code notes (//) the input area was decreased to the vertex widget(which is smaller).但是,当我添加代码注释 (//) 时,输入区域减少到顶点小部件(较小)。 ** _vertex/_edges are hash set of a Vertex/Edges, witch are widget of containers/Line. ** _vertex/_edges 是 Vertex/Edges 的散列集,女巫是容器/线的小部件。
GestureDetector(
child: Container(
width: widget.width,
height: widget.height,
// color: Colors.red,
child: PositionedTapDetector(
onDoubleTap: (position) {
setState(() {
double dx = position.relative.dx;
double dy = position.relative.dy;
Vertex v = new Vertex(posX: dx / 1920, posY: dy / 1920);
this.addVertex(v);
});
},
// child: Stack(
// children: [
// Stack(
// children: _edges.toList(),
// ),
// Stack(
// children: _vertex.toList(),
// ),
// ],
// ),
),
),
);
Here the solution that I found:这是我找到的解决方案:
by adding to PositionedTapDetector behavior: HitTestBehavior.translucent,通过添加到 PositionedTapDetector 行为:HitTestBehavior.translucent,
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.