toJson method

  1. @override
Map<String, dynamic> toJson()
override

Returns a serialized JSON structure of the model, ready to be sent through the API. This does not include fields that are marked as database only.

Implementation

@override
Map<String, dynamic> toJson() {
  return {
    if (id != null) 'id': id,
    'channel': channel,
    'message': message,
    'time': time.toJson(),
    'sender': sender,
    if (senderInfo != null) 'senderInfo': senderInfo?.toJson(),
    'removed': removed,
    if (clientMessageId != null) 'clientMessageId': clientMessageId,
    if (sent != null) 'sent': sent,
    if (attachments != null)
      'attachments': attachments?.toJson(valueToJson: (v) => v.toJson()),
  };
}