MessageNew.fromMap constructor

MessageNew.fromMap(
  1. Map<String, dynamic>? json
)

Implementation

MessageNew.fromMap(Map<String, dynamic>? json) {
  if (json != null) {
    alias = json['alias'];
    avatar = json['avatar'];
    channel = json['channel'];
    emoji = json['emoji'];
    roomId = json['roomId'];
    text = json['text'];

    if (json['attachments'] != null) {
      List<dynamic> jsonList = json['attachments'].runtimeType == String //
          ? jsonDecode(json['attachments'])
          : json['attachments'];
      attachments = jsonList
          .where((json) => json != null)
          .map((json) => MessageAttachment.fromMap(json))
          .toList();
    } else {
      attachments = null;
    }
  }
}