如果我有一个GestureDetector
具有内部GestureDetector
我该如何设置才能使两个检测器都收到点击事件?
您可以在此处查看运行代码:https://dartpad.dev/37807a51a48e52eda81c24cf67260c33 https://dartpad.dev/37807a51a48e52eda81c24cf67260c33
GestureDetector(
onTap: () => print("Log 1"),
child: GestureDetector(
onTap: () => print("Log 2"),
child: Text("CLICK ME")
)
);
class _MyAppState extends State<MyApp> {
@override
Widget build(BuildContext context) {
return RawGestureDetector(
gestures: {
AllowMultipleVerticalDragGestureRecognizer: GestureRecognizerFactoryWithHandlers<
AllowMultipleVerticalDragGestureRecognizer>(
() => AllowMultipleVerticalDragGestureRecognizer(),
(AllowMultipleVerticalDragGestureRecognizer instance) {
instance..onEnd = (_) => print("test1");
},
)
},
child: RawGestureDetector(
gestures: {
AllowMultipleVerticalDragGestureRecognizer: GestureRecognizerFactoryWithHandlers<
AllowMultipleVerticalDragGestureRecognizer>(
() => AllowMultipleVerticalDragGestureRecognizer(),
(AllowMultipleVerticalDragGestureRecognizer instance) {
instance..onEnd = (_) => print("test2");
},
)
},
child: Container(color: Colors.red),
));
}
}
class AllowMultipleVerticalDragGestureRecognizer extends VerticalDragGestureRecognizer{
@override
void rejectGesture(int pointer) {
acceptGesture(pointer);
}
}
Credit: https://gist.github.com/Nash0x7E2/08acca529096d93f3df0f60f9c034056 https://gist.github.com/Nash0x7E2/08acca529096d93f3df0f60f9c034056
本文内容由网友自发贡献,版权归原作者所有,本站不承担相应法律责任。如您发现有涉嫌抄袭侵权的内容,请联系:hwhale#tublm.com(使用前将#替换为@)