flutter-in-action icon indicating copy to clipboard operation
flutter-in-action copied to clipboard

原始指针事件没有书中的效果

Open losedMemory opened this issue 5 years ago • 1 comments

Widget build(BuildContext context) { // TODO: implement build return Container ( child: Stack( children: <Widget>[ Listener( child: ConstrainedBox( constraints: BoxConstraints.tight(Size(300.0, 200.0)), child: DecoratedBox( decoration: BoxDecoration(color: Colors.blue)), ), onPointerDown: (event) => print("down0"), ), Listener( child: ConstrainedBox( constraints: BoxConstraints.tight(Size(200.0, 100.0)), child: DecoratedBox( decoration: BoxDecoration(color: Colors.yellow), ) ), onPointerDown: (event) => print("down1"), behavior: HitTestBehavior.translucent, ) ], ), );

无论怎么更换 behavior点击黄色区域只会打印down1,点击蓝色只会打印down0,没有达到书中的那种穿透效果,是我哪里写的有问题吗

losedMemory avatar Sep 06 '19 03:09 losedMemory

  1. 该示例代码已复核过,没有问题的,另外代码已上传至本书随书源码,可以直接运行
  2. 一定要点击左上角非文字区域

wendux avatar Nov 25 '19 07:11 wendux