Ignore touch events In Flutter

Updated 25 April 2023

Save

All applications now use touch input from the user. In some cases, you may need to disable touch in certain areas or prevent the touch pointer from working. In Flutter, you can use IgnorePointer Widget or AbsorbPointer Widget to ignore the touch events.

You may also check our Flutter app development services.

1. IgnorePointer Widget : IgnorePointer is a built-in widget that protects your child’s widgets from pointer events such as taps, drags, scrolls, and hovers. This widget ignores pointer events without terminating them. This widget is used to prevent unnecessary touch of UI. It is very simple just wrap your widget inside the IgnorePointer widget.

2. AbsorbPointer Widget: AbsorbPointer is a built-in widget in Flutter that absorbs pointers. The main reason this widget exists is to provide the ability to disable the interaction of its subtree widgets at once. In flutter, most widgets currently accompany an alternative to impair them.

Difference between AbsorbPointer and IgnorePointer:

If you have widgets below the main widget that can also receive click events, and you use IgnorePointer on the parent widget, the child widgets will still receive click events. 

However, using AbsorbPointer on the main widget prevents other widgets below the main widget from receiving that click event.

If you have widgets under the main widget that can also receive click events, and you use IgnorePointer on the parent widget, the child widgets will still receive click events. 

But using AbsorbPointer in the main widget prevents other widgets below the main widget from receiving that click event.

Conclusion:

In the article, We have discussed two widgets that used to ignore the touch event in flutter. This was a small introduction to AbsorbPointer and IgnorePointer widgets. I hope this blog will help you to understand these widgets.

Thanks for reading!!


author
. . .

Leave a Comment

Your email address will not be published. Required fields are marked*


Be the first to comment.

Start a Project


    Message Sent!

    If you have more details or questions, you can reply to the received confirmation email.

    Back to Home