class MessageModel { MessageModel({ required this.id, required this.roomId, required this.senderId, required this.body, required this.createdAt, this.kind = 'text', }); final String id; final String roomId; final String senderId; final String body; final String createdAt; final String kind; factory MessageModel.fromJson(Map j) { return MessageModel( id: j['id'] as String, roomId: j['roomId'] as String, senderId: j['senderId'] as String, body: j['body'] as String, createdAt: j['createdAt'] as String, kind: j['kind'] as String? ?? 'text', ); } factory MessageModel.fromWs(Map j) { return MessageModel( id: j['id'] as String, roomId: j['roomId'] as String, senderId: j['senderId'] as String, body: j['body'] as String, createdAt: j['createdAt'] as String, kind: j['kind'] as String? ?? 'text', ); } }