Now this feature is stable, we should use it. I might have missed some usecases, but these can be added in future commits.
22 lines
576 B
Dart
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,
|
|
);
|
|
}
|
|
}
|