showQudsPopupMenu function
void
showQudsPopupMenu({
- required BuildContext context,
- required List<
QudsPopupMenuBase> items, - Offset? startOffset,
- Offset? endOffset,
- Color? backgroundColor,
Show QudsPopupMenu
from calling button
context
the calling build context.
items
the items to be shown in the menu
useRootNavigator
weather to use root navigator
backgroundColor
the background of the popup menu
Implementation
void showQudsPopupMenu(
{required BuildContext context,
required List<QudsPopupMenuBase> items,
bool useRootNavigator = false,
Offset? startOffset,
Offset? endOffset,
Color? backgroundColor}) {
final RenderBox button = context.findRenderObject()! as RenderBox;
final RenderBox overlay =
Navigator.of(context).overlay!.context.findRenderObject()! as RenderBox;
final RelativeRect position = RelativeRect.fromRect(
Rect.fromPoints(
button.localToGlobal(startOffset ?? Offset.zero, ancestor: overlay),
button.localToGlobal(
endOffset ?? (button.size.bottomRight(Offset.zero) + Offset.zero),
ancestor: overlay),
),
Offset.zero & overlay.size,
);
final NavigatorState navigator =
Navigator.of(context, rootNavigator: useRootNavigator);
Navigator.push(
context,
_PopupMenuRoute(
backgroundColor: backgroundColor,
position: position,
items: items,
barrierLabel:
MaterialLocalizations.of(context).modalBarrierDismissLabel,
capturedThemes:
InheritedTheme.capture(from: context, to: navigator.context)));
}