flutter-in-action
flutter-in-action copied to clipboard
原始指针事件没有书中的效果
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,没有达到书中的那种穿透效果,是我哪里写的有问题吗
- 该示例代码已复核过,没有问题的,另外代码已上传至本书随书源码,可以直接运行
- 一定要点击左上角非文字区域