I'm using showMenu() to dispaly popup menu. Usually when you use PopupMenuButton it has the onSelected option, but you don't seem to have it with showMenu().
I tried wrapping the contents of PopupMenuItem inside GestureDetector, but that makes the clickable area just way too small. See picture below, the smaller rectangle is my GestureDetector (which works but is too small) and the bigger rectangle is the inkwell which comes with PopupMenuItem.
So my question is, how should I handle PopupMenuItem presses when I don't have the onSelected property?
EDIT:
Here is the code. I have ListTiles, which call this method on LongPress:
void _showOptionsMenu(int hiveIndex) {
final RenderBox overlay = Overlay.of(context).context.findRenderObject();
showMenu(
context: context,
position: RelativeRect.fromRect(
// magic code from stackoverflow, positions the PopupMenu on your tap location
_tapPosition & Size(40, 40),
Offset.zero & overlay.size,
),
items: [
PopupMenuItem(
value: 0,
child: Row(
children: [
Icon(Icons.edit),
Text("Edit"),
],
),
),
PopupMenuItem(
value: 1,
child: Row(
children: [
Icon(Icons.delete),
Text("Delete"),
],
),
),
],
);
You can't wrap the PopupMenuItems inside GestureDetector, since the items property only allows PopupMenuItems.
