I'm trying to wrap my whole app in a widget that will prevent touch event being passed down through the view hierarchy based on some condition. I already have a WrapperlifecycleListener
in place:
@override
Widget build(BuildContext context) {
return WrapperAppLifecycleListener(
child: Listener(
onPointerDown: (_) {
//other stuff I do
},
child: MyApp(),
),
);
}
I was expecting to be able to do something like this:
onPointerDown: (_) {
if(passThrough){
return true;
} else {
return false;
}
},
but all the widget I found so far all have void
as return type of their callbacks, is there any widget that does something like that?
EDIT: the condition changes when the user interact with the app itself, so IgnorePointer or AbsorbPointer would not work in this case. To be clearer consider a case where I want to disable all touch inputs after a touch input, so hypotetically:
@override
Widget build(BuildContext context) {
return WrapperAppLifecycleListener(
child: Listener(
onPointerDown: (_) {
if(absorb){
return false;
} else {
return true;
}
absorb = true;
Future.delayed(Duration(seconds:2)).then((value) => absorb = false);
},
child: MyApp(),
),
);
}