import 'dart:convert'; import 'package:muaawana/models/auth/current_user_response.dart'; import 'chat_v2/message.dart'; NotificationModel notificationFromJson(String str) => NotificationModel.fromJson(json.decode(str)); String notificationToJson(NotificationModel data) => json.encode(data.toJson()); class NotificationModel { String? action; MessageModel? chat; int? id; int? actionId; CurrentUser? reciver; CurrentUser? sender; String? status; int? timestmp; String? subject; String? content; String? logUrl; MessageModel? meeting; NotificationModel({ this.action, this.chat, this.id, this.actionId, this.subject, this.content, this.reciver, this.sender, this.status, this.timestmp, this.logUrl, this.meeting, }); NotificationModel.fromJson(dynamic json) { action = json['action']; chat = json['chat'] != null ? MessageModel.fromJson(json['chat']) : null; id = json['id']; actionId = json['actionId']; // Fixed: was overwriting id reciver = json['reciver'] != null ? CurrentUser.fromJson(json['reciver']) : null; sender = json['sender'] != null ? CurrentUser.fromJson(json['sender']) : null; status = json['status']; timestmp = json['timestmp']; subject = json['subject']; content = json['content']; logUrl = json['logUrl']; meeting = json['meeting'] != null ? MessageModel.fromJson(json['meeting']) : null; } Map toJson() { final map = {}; map['action'] = action; if (chat != null) { map['chat'] = chat?.toJson(); } map['id'] = id; map['actionId'] = actionId; if (reciver != null) { map['reciver'] = reciver?.toJson(); } if (sender != null) { map['sender'] = sender?.toJson(); } map['status'] = status; map['timestmp'] = timestmp?.toString(); map['subject'] = subject; map['content'] = content; map['logUrl'] = logUrl; if (meeting != null) { map['meeting'] = meeting?.toJson(); } return map; } }