Chat.fromJson constructor
Implementation
factory Chat.fromJson(Map<String, dynamic> json) {
return Chat(
chatID: json['chatID'],
user: User.fromJson(json['user']),
lastmessage: json['lastmessage'] == null
? null
: ChatMessage.fromJson(json['lastmessage']).obs,
messages: json['messages'] == null
? Rxn<List<ChatMessage>>()
: Rxn<List<ChatMessage>>(
(json['messages'] as List<dynamic>?)
?.map((member) => ChatMessage.fromJson(member))
.toList(),
),
chatType: APIChat.values.firstWhere(
(e) => e.name == json['chatType'],
orElse: () => APIChat.ozel, // veya varsayılan olarak ne istiyorsan
),
chatNotification: (json['chatNotification'] as bool).obs,
calling: (json['calling'] as bool?)?.obs ?? false.obs,
);
}