SmsMessage.fromJson constructor

SmsMessage.fromJson(
  1. Map data
)

Read message from JSON

Format:

{
  "address": "phone-number-here",
  "body": "text message here"
}

Implementation

factory SmsMessage.fromJson(Map data) {
  final date = data['date'];
  final dateSent = date['date_sent'];
  return SmsMessage(
    address: data['address'],
    body: data['body'],
    id: data['_id'],
    threadId: data['thread_id'],
    date: date == null ? null : DateTime.fromMillisecondsSinceEpoch(date),
    dateSent: dateSent == null ? null : DateTime.fromMillisecondsSinceEpoch(dateSent),
  );
}