Flutter: Block Gestures to underneath widgets

Viewed 1848

I have a stack with some widget, and I want tat the most in top widget blocks all the gestures to the underneath widgets.

I've tried with a GestureDetector and opaque behaviour but does not work.

What is the correct approach?

2 Answers

You can use the IgnorePointer widget to block any gesture for it's child.

IgnorePointer(
    child: MyWidget(),
    ignoring: true, // or false to disable this behavior
)

Also any widget that is partially overflowing the stack will not receive gestures.

If you have shared some code, that would be better, so now I can just give you an idea, you can try AbsorbPointer.

AbsorbPointer(child: YourWidget())
Related