toMap method
Implementation
Map<String, dynamic> toMap() {
Map<String, dynamic> map = {};
if (id != null) {
map['_id'] = id;
}
if (alias != null) {
map['alias'] = alias;
}
if (msg != null) {
map['msg'] = msg;
}
if (parseUrls != null) {
map['parseUrls'] = parseUrls;
}
if (bot != null) {
map['bot'] = bot != null ? bot!.toMap() : null;
}
if (groupable != null) {
map['groupable'] = groupable;
}
if (t != null) {
map['t'] = t;
}
if (ts != null) {
map['ts'] = ts!.toIso8601String();
}
if (user != null) {
map['u'] = user != null ? user!.toMap() : null;
}
if (rid != null) {
map['rid'] = rid;
}
if (updatedAt != null) {
map['_updatedAt'] = updatedAt!.toIso8601String();
}
if (reactions != null) {
map['reactions'] = reactions!.map((a, b) => MapEntry(a, b.toMap()));
}
if (mentions != null) {
map['mentions'] = mentions
?.where((json) => json != null)
?.map((mention) => mention.toMap())
?.toList() ??
[];
}
if (channels != null) {
map['channels'] = channels;
}
if (starred != null) {
map['starred'] = starred;
}
if (emoji != null) {
map['emoji'] = emoji;
}
if (avatar != null) {
map['avatar'] = avatar;
}
if (attachments != null) {
map['attachments'] = attachments
?.where((json) => json != null)
?.map((attachment) => attachment.toMap())
?.toList() ??
[];
}
if (editedBy != null) {
map['editedBy'] = editedBy != null ? editedBy!.toMap() : null;
}
if (editedAt != null) {
map['editedAt'] = editedAt!.toIso8601String();
}
if (urls != null) {
map['urls'] = urls;
}
return map;
}