parseAttachment method

Attachment parseAttachment(
  1. Map<String, Object?> raw
)

Implementation

Attachment parseAttachment(Map<String, Object?> raw) {
  return Attachment(
    id: Snowflake.parse(raw['id']!),
    manager: this,
    fileName: raw['filename'] as String,
    description: raw['description'] as String?,
    contentType: raw['content_type'] as String?,
    size: raw['size'] as int,
    url: Uri.parse(raw['url'] as String),
    proxiedUrl: Uri.parse(raw['proxy_url'] as String),
    height: raw['height'] as int?,
    width: raw['width'] as int?,
    isEphemeral: raw['ephemeral'] as bool? ?? false,
    duration: maybeParse(raw['duration_secs'], (double value) => Duration(microseconds: (value * Duration.microsecondsPerSecond).floor())),
    waveform: maybeParse(raw['waveform'], base64.decode),
    flags: maybeParse(raw['flags'], AttachmentFlags.new),
  );
}