作者:王柱柱 | 来源:互联网 | 2022-12-09 17:36
有什么方法可以使GestureDetector覆盖所有子GestureDetectors的功能?
我有一个复杂的Widget,我希望能够轻松地从高级别覆盖其所有行为。例如,将自由用户锁定在功能之外。
1> boformer..:
要暂时禁用所有子手势检测器,请使用IgnorePointer
小部件:
@override
Widget build(BuildContext context) {
bool ignoreChildGestures = true;
return GestureDetector(
onTap: () {
print('parent tapped');
},
child: IgnorePointer(
ignoring: ignoreChildGestures,
child: GestureDetector(
onTapDown: (details) {
// won't be called when ignoring is set to true
print('child tap down!');
},
),
),
);
}