0

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!

Magnus
  • 17,157
  • 19
  • 104
  • 189

1 Answers1

0
GestureDetector(
          behavior: HitTestBehavior.opaque,
          onTap: () => print('Tapped'),
          child: AppBody(),
        )
cloudpham93
  • 524
  • 1
  • 4
  • Thanks, I didn't think you could wrap the entire app in a GestureDetector! However, this wont detect taps on the keyboard unfortunately. Is there any way to do that? I tried using `window.onKeyData` but I couldn't get it to work. – Magnus Aug 19 '22 at 12:55