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

Hamed
- 5,867
- 4
- 32
- 56
1 Answers
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(),
)
-
worth adding that events not specifically handled by the GestureDetector will also not be ignored – Pjotr Gainullin Oct 12 '22 at 03:24