1
0
Fork 0
forked from Nexus/nexus
nexus/lib/helpers/extensions/show_context_menu.dart
Henry-Hiles d2ec5f035b
treewide: use dot shorthands where possible
Now this feature is stable, we should use it. I might have missed some usecases, but these can be added in future commits.
2026-06-02 12:50:56 -04:00

22 lines
576 B
Dart

import "package:flutter/material.dart";
extension ShowContextMenu on BuildContext {
void showContextMenu({
required Offset globalPosition,
required List<PopupMenuEntry> children,
}) {
final overlay = Overlay.of(this).context.findRenderObject() as RenderBox;
showMenu(
context: this,
constraints: .loose(Size.infinite),
position: .fromLTRB(
globalPosition.dx,
globalPosition.dy,
overlay.size.width - globalPosition.dx,
overlay.size.height - globalPosition.dy,
),
items: children,
);
}
}