Search code examples
flame

How to disable or ignore background screen's touch events after loading an overlay?


In flutter flame, after tapping on pause button on score overlay at the top, I pause the game engine, and display a little pause overlay window at the center of the screen, but score overlay which is visible in the background still is tappable. I want to disable all the touch events behind pause overlay window. I couldn't find a workaround using AbsorbPointer and IgnorePointer Widgets.

  1. Disable underlying tap events behind active overlay? or
  2. Dismissing the overlay window by tapping outside of it?

Solution

  • There is some talk about this situation here.

    What you could do is add a GestureDetector that covers the full screen in your overlay, something like this:

    GestureDetector(
      behavior: HitTestBehavior.opaque,
      onTap: () {
        ...
      },
      child: <<Your current overlay>>,
    );