toJson method

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

Returns the information stored in this object in a way the it could be encoded via jsonEncode().

Implementation

@override
Map<String, dynamic> toJson() {
  final Map<String, dynamic> newJson = super.toJson();
  newJson[BrokerKeys.messageType] = BrokerKeys.userMessage;
  if (attachment != null)
    newJson[BrokerKeys.attachments] = attachment!.toJson();
  if (subject != null) newJson[BrokerKeys.subject] = subject;
  if (text != null) newJson[BrokerKeys.text] = text;
  return newJson;
}