debugBuildContextMenuPayload function

  1. @visibleForTesting
Map<String, Object?> debugBuildContextMenuPayload({
  1. required List<CNPopupMenuEntry> items,
  2. required Offset position,
  3. required int? resolveColor(
    1. Color? color
    ),
  4. bool? isDark,
  5. Map<PopupMenuIconKey, Uint8List?> customIconBytes = const {},
  6. Map<CNPopupMenuEntry, String> assetPaths = const {},
})

Builds the method channel payload of showNativeContextMenu.

Exposed for tests: the payload is the contract shared with CNContextMenuManager.swift on both platforms.

Implementation

@visibleForTesting
Map<String, Object?> debugBuildContextMenuPayload({
  required List<CNPopupMenuEntry> items,
  required Offset position,
  required int? Function(Color? color) resolveColor,
  bool? isDark,
  Map<PopupMenuIconKey, Uint8List?> customIconBytes = const {},
  Map<CNPopupMenuEntry, String> assetPaths = const {},
}) {
  return <String, Object?>{
    'menu': encodePopupMenuEntries(
      items,
      resolveColor: resolveColor,
      customIconBytes: customIconBytes,
      assetPaths: assetPaths,
    ),
    'x': position.dx,
    'y': position.dy,
    'isDark': ?isDark,
  };
}