MessageNotificationModel.fromJsonData constructor

MessageNotificationModel.fromJsonData(
  1. Map<String, dynamic> jsonData
)

Implementation

MessageNotificationModel.fromJsonData(Map<String, dynamic> jsonData) {
  id = TypeSafeConversion.nullSafeInt(jsonData['id']);
  title = TypeSafeConversion.nullSafeString(jsonData['title']);
  body = TypeSafeConversion.nullSafeString(jsonData['body']);
  userId = TypeSafeConversion.nullSafeString(jsonData['userId']);
  String img = TypeSafeConversion.nullSafeString(jsonData['imagePath']);
  imagePath = (img.isNotEmpty)
      ? img.startsWith('http')
          ? jsonData['imagePath']
          : '${ApiConstantDev.urlServerImageNotification}/$img'
      : '';
  payload = ((jsonData['payload']) == null)
      ? PayLoadModel()
      : PayLoadModel.fromJson(json.decode(jsonData['payload']));
  channel = ((jsonData['channel']) == null)
      ? ChannelModel()
      : ChannelModel.fromJson(json.decode(jsonData['channel']));
}