Flutter點選事件的穿透,父元素點選事件覆蓋了子元素點選的問題
阿新 • • 發佈:2020-12-02
在web 中類似的情況的都被成為點選穿透事件
在flutter中 ,元件的巢狀 也存在類似情況,flutter中的所有點選事件 一層一層原始碼找 最終都是
有興趣可以去看官方文件
https://flutterchina.club/gestures/
GestureDetector點選 元件的原始碼中的behavior 屬性
三個內容 列舉 值
//方法1 ... InkWell( onTap: () {}, child: GestureDetector( behavior:HitTestBehavior.translucent, onTap:(){ print("___test"); print("---"); }, child: Text("點選", ), ), ); ...
//方法2 ... InkWell( onTap:(){}, child: Container( color:Colors.transparent,//透明顏色 child: GestureDetector( onTap:(){ print("___test"); print("---"); }, child: Text("點選", style:TextStyleConstant().blue_16, ), ), ), ) ....