Attachment.fromJson constructor

Attachment.fromJson(
  1. dynamic jsonData
)

Implementation

Attachment.fromJson(dynamic jsonData) {
  Map<String, dynamic> decoded = credentialToMap(jsonData);
  if (decoded.containsKey('data')) {
    data = AttachmentData.fromJson(decoded['data']);
  } else {
    throw FormatException('an Attachment must contain a data property');
  }

  id = decoded['id'];
  description = decoded['description'];
  filename = decoded['filename'];
  mediaType = decoded['media_type'];
  format = decoded['format'];
  if (decoded.containsKey('lastmod_time') &&
      decoded['lastmod_time'] != null) {
    lastmodTime = DateTime.fromMillisecondsSinceEpoch(
        decoded['lastmod_time'] * 1000,
        isUtc: true);
  }
  byteCount = decoded['byte_count'];
}