一.您需要做的是将整个屏幕(或某个区域)包裹在GestureDetector小部件中并监听事件,如下所示:
1.onTapDown或onTapUp
GestureDetector(
onTapDown: (details){
final tapPosition = details.globalPosition; final x = tapPosition.dx; final y = tapPosition.dy; // do something with x & y
},
child: Scaffold(/* ...*/)
)
2.onLongPressStart
GestureDetector(
onLongPressStart: (olpdt) async {
var menuResult = await showRightMenu(context,
olpdt.globalPosition.dx,
olpdt.globalPosition.dy,
items: [ MapEntry("修改", eventMenuItems.edit),
MapEntry("删除", eventMenuItems.delete)]);