GestureDetector(
onLongPressDown: (details) {
setState(() {
dx = details.globalPosition.dx;
dy = details.globalPosition.dy;
});
},
onLongPress: () {
showMenu(
context: context,
///这个坐标值不好调整,下面我的经验值,位置在手指点击点的左下方,想往左移动给110+数字 往下移动180加数字
position: RelativeRect.fromLTRB(dx, dy, dx + 110, dy - 40),
items: [
///建议指定value属性
PopupMenuItem<String>(
value: 'one',
onTap: () => debugPrint('tap one'),
child: const Text('删除'),
),
PopupMenuItem<String>(
value: 'two',
onTap: () => debugPrint('tap two'),
child: const Text('管理列表'),
),
],
);
},
child: Text(“你好”),
);