fromMap static method

ChatEntity? fromMap(
  1. Object? o, {
  2. Map<String, String>? newDocumentIds,
})

Implementation

static ChatEntity? fromMap(Object? o, {Map<String, String>? newDocumentIds}) {
  if (o == null) return null;
  var map = o as Map<String, dynamic>;

  var chatMediaFromMap = map['chatMedia'];
  List<ChatMediumEntity> chatMediaList;
  if (chatMediaFromMap != null) {
    chatMediaList = (map['chatMedia'] as List<dynamic>)
        .map((dynamic item) => ChatMediumEntity.fromMap(item as Map,
            newDocumentIds: newDocumentIds)!)
        .toList();
  } else {
    chatMediaList = [];
  }

  return ChatEntity(
    authorId: map['authorId'],
    appId: map['appId'],
    roomId: map['roomId'],
    timestamp: map['timestamp'] == null
        ? null
        : (map['timestamp'] as Timestamp).millisecondsSinceEpoch,
    saying: map['saying'],
    accessibleByGroup: map['accessibleByGroup'],
    accessibleByMembers: map['accessibleByMembers'] == null
        ? null
        : List.from(map['accessibleByMembers']),
    readAccess:
        map['readAccess'] == null ? null : List.from(map['readAccess']),
    chatMedia: chatMediaList,
  );
}