How can I ignore drag with IgnorePointer?

606 Views Asked by At

I know we can ignore pointer with the IgnorePointer widget, but how can I ignore just a specific event. for example, VerticalDrag or tap?

1

There are 1 best solutions below

1
On BEST ANSWER

If you want to ignore a specific event, in your case VerticalDrag on a widget Container, you would have to wrap the widget in question in a GestureDetector

GestureDetectors would always try and respond to events with non-null callbacks.

So putting that all together, a simple code snippet to achieve what you wanted would probably look like this

GestureDetector(
        // Ignores all this events

        onVerticalDragUpdate: (_) {},

        onVerticalDragDown: (_) {},

        onVerticalDragEnd: (_) {},

        onVerticalDragStart: (_) {},

        onVerticalDragCancel: () {},

        onTap: () {},

        // Does not ignore these events below

        onDoubleTap: () {
          print('Container was double tapped');
        },
        onLongPress: () {
          print('Container was long pressed');
        },

        child: Container(),
      )