Skip to content

Instantly share code, notes, and snippets.

@bistole
Created March 17, 2021 20:22
Show Gist options
  • Save bistole/da5817979206b9dd378ab5ab50df50a4 to your computer and use it in GitHub Desktop.
Save bistole/da5817979206b9dd378ab5ab50df50a4 to your computer and use it in GitHub Desktop.
popup menu
void popupMenu(BuildContext context, ReduxActions redux) {
GlobalKey gKey =
getViewResource().getGlobalKeyByName("PHOTO-LIST:" + widget.uuid);
Rect gridRect = getViewResource().getRectFromWidget(gKey);
Rect allRect = Offset.zero & Overlay.of(context).context.size;
List<PopupMenuEntry> items = [
PopupMenuItem<String>(
child: Text('Delete'),
value: 'delete',
),
PopupMenuItem<String>(
child: Text('Show'),
value: 'show',
),
];
showMenu(
context: context,
position: RelativeRect.fromRect(
Rect.fromCenter(center: gridRect.center, width: 2, height: 2),
allRect,
),
items: items,
).then((value) {
if (value == 'delete') {
redux.delete();
} else if (value == 'show') {
Navigator.of(context).pushNamed(
PhotoPage.routeName,
arguments: PhotoPageArguments(redux.photo.uuid),
);
}
});
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment