NotificationItem.fromJson constructor

NotificationItem.fromJson({
  1. required dynamic jsonObject,
})

Implementation

factory NotificationItem.fromJson({
  required dynamic jsonObject,
}) {
  final notificationItem = NotificationItem();
  notificationItem.title = jsonObject["title"];
  notificationItem.body = jsonObject["title"];
  notificationItem.isRead = jsonObject["isRead"];
  notificationItem.date = DateTime.tryParse(jsonObject["createdAt"])?.toLocal()??DateTime.now();

  return notificationItem;
}