ChatRoom.fromJson constructor

ChatRoom.fromJson(
  1. Map<String, dynamic> json,
  2. String id
)

Implementation

ChatRoom.fromJson(Map<String, dynamic> json, String id)
    : id = json['id'] ?? id,
      createdOn = DateTime.parse(json['createdOn']),
      updatedOn = json['updatedOn'] != null
          ? DateTime.parse(json['updatedOn'])
          : null,
      type = json['type'],
      subscriptionType = json['subscriptionType'],
      lastMessage = json['lastMessage'] != null
          ? ChatMessage.fromJson(json['lastMessage'], "")
          : null,
      membersId = List<String>.from(json['membersId']),
      members = Map<String, UserModel>.from(
        json['members'].map(
          (key, value) => MapEntry(key, UserModel.fromJson(value)),
        ),
      );