debugEncodePopoverContent function

  1. @visibleForTesting
Map<String, Object?> debugEncodePopoverContent(
  1. CNPopoverContent content, {
  2. BuildContext? context,
})

Encodes content for the native side.

Exposed for tests: it is the contract shared with CNPopoverManager.swift on both platforms.

Implementation

@visibleForTesting
Map<String, Object?> debugEncodePopoverContent(
  CNPopoverContent content, {
  BuildContext? context,
}) => {
  if ((content.title ?? '').isNotEmpty) 'title': content.title,
  if ((content.message ?? '').isNotEmpty) 'message': content.message,
  if (content.gauges.isNotEmpty)
    'gauges': [
      for (final gauge in content.gauges)
        {
          'label': gauge.label,
          'fraction': gauge.fraction,
          if (gauge.valueText != null) 'valueText': gauge.valueText,
          if (gauge.tint != null)
            'tint': context != null && context.mounted
                ? resolveColorToArgb(gauge.tint, context)
                : gauge.tint!.toARGB32(),
        },
    ],
  'rows': [
    for (final row in content.rows)
      {
        ...encodeListItem(row.item),
        'id': row.id,
        'checked': row.checked,
        'enabled': row.enabled,
        if (row.readOnly) 'readOnly': true,
      },
  ],
  'toggles': [
    for (final toggle in content.toggles)
      {
        'id': toggle.id,
        'label': toggle.label,
        'value': toggle.value,
        'enabled': toggle.enabled,
        if (toggle.subtitle != null) 'subtitle': toggle.subtitle,
        if (toggle.symbol != null) 'sfSymbol': toggle.symbol!.name,
      },
  ],
  'actions': [
    for (final action in content.actions)
      {
        if (action.id != null) 'id': action.id,
        'label': action.label,
        'style': _actionStyleName(action.style),
      },
  ],
};