toJson method Null safety

Map<String, dynamic> toJson()

Implementation

Map<String, dynamic> toJson() {
  final ret = <String, dynamic>{
    'custom_type': customType,
    'data': data,
    'mention_type': mentionType?.asString(),
    'mentioned_user_ids': mentionedUserIds,
    'sorted_metaarray': metaArrays?.map((e) => e.toJson()).toList(),
    if (pushOption == PushNotificationDeliveryOption.suppress)
      'push_option': pushOption.asString(),
    if (parentMessageId != null) 'parent_message_id': parentMessageId,
  };

  ret.removeWhere((key, value) => value == null);
  return ret;
}