fromJson static method

ChatContent fromJson(
  1. Map<String, dynamic> chatMap
)

Implementation

static ChatContent fromJson(Map<String, dynamic> chatMap) {
  List<MessageContent> msgs = [];

  for (var item in chatMap['msgContents']) {
    msgs.add(MessageContent.fromJson((item)));
  }

  return ChatContent(
    chatName: chatMap['chatName'],
    sizeOfChat: chatMap['sizeOfChat'],
    members: List<String>.from(chatMap['names']),
    messages: msgs,
    msgsPerMember: Map<String, int>.from(chatMap['msgsPerPerson']),
    imagesPaths: chatMap['imagesPaths'] != null
        ? List<String>.from(chatMap['imagesPaths'])
        : null,
    indexesPerMember: chatMap['indexesPerPerson'] == null
        ? {}
        : _toIndexesPerMember(
            Map<String, dynamic>.from(chatMap['indexesPerPerson'])),
  );
}