Welcome to OStack Knowledge Sharing Community for programmer and developer-Open, Learning and Share
Welcome To Ask or Share your Answers For Others

Categories

0 votes
944 views
in Technique[技术] by (71.8m points)

dart - 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.

See Question&Answers more detail:os

与恶龙缠斗过久,自身亦成为恶龙;凝视深渊过久,深渊将回以凝视…
Welcome To Ask or Share your Answers For Others

1 Answer

0 votes
by (71.8m points)

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.

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

You can adjust this attribute by changing the bool value of ignoring:

IgnorePointer(ignoring: false, ...)

This will enable all touch events again.

Absorbing

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.


与恶龙缠斗过久,自身亦成为恶龙;凝视深渊过久,深渊将回以凝视…
Welcome to OStack Knowledge Sharing Community for programmer and developer-Open, Learning and Share
Click Here to Ask a Question

...