Flutter: Block Gestures to underneath widgets

醉酒当歌 提交于 2020-02-04 12:16:27

问题


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?


回答1:


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())



回答2:


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.



来源:https://stackoverflow.com/questions/56771482/flutter-block-gestures-to-underneath-widgets

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!