两种解决方案:
- 通过Stack布局,解除两个widget的嵌套关系
2.通过IgnorePointer忽视事件传递
body: Center(
child: Stack(
alignment: Alignment.center,
children: [
GestureDetector(
onTapDown: (gesture){
print("绿色");
},
child: Container(
height: 200,
width: 200,
color: Colors.green,
),
),
IgnorePointer(
child: GestureDetector(
onTapDown: (gesture){
print("红色");
},
child: Container(
height: 100,
width: 100,
color: Colors.red,
),
),
)
],
)
),