1

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

Hamed
  • 5,867
  • 4
  • 32
  • 56

1 Answers1

3

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(),
      )
Dharman
  • 30,962
  • 25
  • 85
  • 135
Adeolaex
  • 179
  • 10