toMap method

Map<String, dynamic> toMap()

Implementation

Map<String, dynamic> toMap() {
  // Gated on the serialized map being non-empty, not on the object being non-null: a
  // NotificationInboxAccessibilityLabels with every field unset serializes to {}, and sending
  // that would make "the host configured nothing" indistinguishable from "the host configured
  // an empty object" on the native side, where both parsers key off the map's presence.
  final Map<String, dynamic>? labels = accessibilityLabels?.toMap();
  return {
    'siteId': siteId,
    // Omitted rather than defaulted to 'auto': the native SDKs already default to AUTO, and
    // sending a value the host never set would make "follow the device" indistinguishable
    // from an explicit choice.
    if (colorScheme != null) 'colorScheme': colorScheme!.rawValue,
    if (labels != null && labels.isNotEmpty)
      'notificationInboxAccessibilityLabels': labels,
  };
}