debugBuildActionSheetPayload function

  1. @visibleForTesting
Map<String, Object?> debugBuildActionSheetPayload({
  1. required List<CNActionSheetAction<Object?>> actions,
  2. String? title,
  3. String? message,
  4. String? cancelLabel,
  5. Rect? anchorRect,
})

Builds the method channel payload for CNActionSheet.show.

Exposed for tests: the payload is the contract shared with CNActionSheetManager.swift, so it is asserted directly rather than through a platform round trip.

Implementation

@visibleForTesting
Map<String, Object?> debugBuildActionSheetPayload({
  required List<CNActionSheetAction<Object?>> actions,
  String? title,
  String? message,
  String? cancelLabel,
  Rect? anchorRect,
}) {
  return <String, Object?>{
    'title': title,
    'message': message,
    'cancelLabel': cancelLabel,
    'actions': [
      for (final action in actions)
        <String, Object?>{
          'label': action.label,
          'destructive': action.isDestructive,
          'enabled': action.enabled,
        },
    ],
    if (anchorRect != null)
      'anchorRect': <String, double>{
        'x': anchorRect.left,
        'y': anchorRect.top,
        'width': anchorRect.width,
        'height': anchorRect.height,
      },
  };
}