toJson method

Map<String, dynamic> toJson()

Implementation

Map<String, dynamic> toJson() {
  Map<String, dynamic> data = <String, dynamic>{};
  if (recipientId != null) {
    data["recipient"] = {
      "id": recipientId,
    };
  }

  if (senderId != null) {
    data["sender"] = {
      "id": senderId,
    };
  }

  if (message != null) {
    data["message"] = [];
    for (MessageModel i in message!) {
      data["message"].add(i.toJson());
    }
  }
  return data;
}