FileAttachment.fromJson constructor

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

Creates a FileAttachment from a JSON map (database storage format).

Implementation

factory FileAttachment.fromJson(Map<String, dynamic> json) {
  return FileAttachment(
    id: json['id'] as String? ?? '',
    url: json['url'] as String? ?? '',
    name: json['name'] as String? ?? '',
    extension: json['ext'] as String? ?? '',
    size: json['size'] as int? ?? 0,
    mimeType: json['mimeType'] as String?,
    pageCount: json['pageCount'] as int?,
    thumbnailUrl: json['thumbnailUrl'] as String?,
    uploadStatus: FileUploadStatus.completed,
    localPath: json['localPath'] as String?,
    width: json['width'] as int?,
    height: json['height'] as int?,
    thumbhash: json['thumbhash'] as String?,
    blurhash: json['blurhash'] as String?,
    duration: json['durationMs'] != null
        ? Duration(milliseconds: json['durationMs'] as int)
        : null,
    waveform: (json['waveform'] as List<dynamic>?)
        ?.map((e) => (e as num).toDouble())
        .toList(),
  );
}