Flutter:忽略小部件上的触摸事件 [英] Flutter: Ignore touch events on a Widget
问题描述
我想在其他小部件上放置模糊的图像,但是,当我这样做时,我无法与其下方的小部件进行交互。
I want to have a blurred image on top of my other widgets, however, I cannot interact with the widgets below it when I do that.
推荐答案
解决方案
您可以解决交互问题(无法与小部件
在模糊图像下方),将 BackdropFilter
用 IgnorePointer
。
Solution
You can solve your interaction issue (not being able to interact with the Widget
below your blurred image) by surrounding your BackdropFilter
with an IgnorePointer
.
这意味着 IgnorePointer
是解决方案,因为它会忽略所有小部件
作为其子项传递的触摸事件。
This means that IgnorePointer
is the solution here because it will ignore all touch events for the Widget
's passed as its child.
IgnorePointer(child: BackdropFilter(...),)
您可以通过更改忽略的
: bool
值来调整此属性
You can adjust this attribute by changing the bool
value of ignoring
:
IgnorePointer(ignoring: false, ...)
这将再次启用所有触摸事件。
AbsorbPointer
小工具
,它可用于反映在其子对象自身上发生的所有触摸事件。
Something interesting to look at here, but unrelated to the problem, is the AbsorbPointer
Widget
, which can be used to reflect all touch events that occur on its child onto itself.
这篇关于Flutter:忽略小部件上的触摸事件的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!