I know I can use a GestureDetector
to detect taps on other widgets. But what if I want to detect any and all taps, no matter what is being displayed at the moment - i.e. even if a dialog or menu is being displayed in front of the current page. Is there any way to do this without wrapping each dialog in a GestureDetector
and manually implementing tap detection and notifying my tap detection method from each and every possible dialog that could be displayed in the app?
I don't want to intercept or stop the taps from propagating, just detect that the user touched the screen. The reason is that I have a method that should be run if the user hasn't touched the screen for 5 minutes (the user checks out a resource, and it needs to be automatically checked in if the user didn't touch the screen for a while).
I currently have it implemented and working for the page that displays the checked out data (it's basically a form with lots of fields). The problem is that some parts of the form open dialogs that can take a while for the user to fill out, so right now the main page/form gets checked in if the user takes more than 5 minutes to fill out the data in the dialog and close it.
Basically the most convenient approach would be either some kind of global touch-detector, or some way to display a GestureDetector
on top of everything on the screen - including dialogs!
GestureDetector(
behavior: HitTestBehavior.opaque,
onTap: () => print('Tapped'),
child: AppBody(),
)