ChatModel.fromJson constructor

ChatModel.fromJson(
  1. Map<String, dynamic> json
)

Implementation

factory ChatModel.fromJson(Map<String, dynamic> json) {
  return ChatModel(
    id: json['id'],
    isGroup: json['is_group'] ?? false,
    name: json['name'],
    picture: json['picture'],
    createdBy: json['created_by'],
    createdAt: json['created_at'],
    updatedAt: json['updated_at'],
    encryptionKey: json['encryption_key'],
    latestMessageId: json['latest_message_id'],
    members: (json['chat_members'] as List)
        .map((member) => ChatMember.fromJson(member))
        .toList(),
    latestMessage: json['messages'] != null
        ? ChatMessageModel.fromJson(json['messages'])
        : null,
  );
}