Message.fromJson constructor

Message.fromJson(
  1. Map<String, dynamic> json
)

Implementation

factory Message.fromJson(Map<String, dynamic> json) {
  return Message(
    id: json['id'] ?? '',
    type: json['type'] ?? '',
    from: json['from'] != null
        ? List<MessageAddress>.from(
            json['from'].map((item) => MessageAddress.fromJson(item)))
        : const [],
    to: json['to'] != null
        ? List<MessageAddress>.from(
            json['to'].map((item) => MessageAddress.fromJson(item)))
        : const [],
    cc: json['cc'] != null
        ? List<MessageAddress>.from(
            json['cc'].map((item) => MessageAddress.fromJson(item)))
        : const [],
    bcc: json['bcc'] != null
        ? List<MessageAddress>.from(
            json['bcc'].map((item) => MessageAddress.fromJson(item)))
        : const [],
    received: json['received'] ?? '',
    subject: json['subject'] ?? '',
    html: json['html'] != null ? MessageContent.fromJson(json['html']) : const MessageContent(),
    text: json['text'] != null ? MessageContent.fromJson(json['text']) : const MessageContent(),
    attachments: json['attachments'] != null
        ? List<Attachment>.from(
            json['attachments'].map((item) => Attachment.fromJson(item)))
        : const [],
    metadata: json['metadata'] != null
        ? Metadata.fromJson(json['metadata'])
        : const Metadata(),
    server: json['server'] ?? '',
  );
}