RichMediaAnnotation.fromJson constructor

RichMediaAnnotation.fromJson(
  1. Map<String, dynamic> json, [
  2. Map<String, dynamic>? attachments
])

Implementation

factory RichMediaAnnotation.fromJson(Map<String, dynamic> json,
    [Map<String, dynamic>? attachments]) {
  final String mediaAttachmentId = json['mediaAttachmentId'] as String? ?? '';

  return RichMediaAnnotation(
    id: json['id'] as String?,
    bbox: Annotation._toDoubleList(json['bbox'] as List),
    createdAt: json['createdAt'] as String?,
    creatorName: json['creatorName'] as String?,
    contentType: json['contentType'] as String?,
    fileName: json['fileName'] as String?,
    description: json['description'] as String?,
    mediaAttachmentId: mediaAttachmentId,
    mediaSource: json['mediaSource'] as String? ?? 'richMedia',
    encoding: json['encoding'] != null
        ? Map<String, dynamic>.from(json['encoding'] as Map)
        : null,
    mediaType: json['mediaType'] as String?,
    source: json['source'] as String?,
    params: json['params'] != null
        ? Map<String, dynamic>.from(json['params'] as Map)
        : null,
    pageIndex: json['pageIndex'] as int,
    opacity:
        json['opacity'] != null ? Annotation._toDouble(json['opacity']) : 1.0,
    pdfObjectId: json['pdfObjectId'] as int?,
    flags: Annotation._stringsToFlags(json['flags'] as List<dynamic>?),
    updatedAt: json['updatedAt'] as String?,
    name: json['name'] as String?,
    subject: json['subject'] as String?,
    hidden: json['hidden'] as bool? ?? false,
    customData: json['customData'] != null
        ? Map<String, dynamic>.from(json['customData'])
        : null,
    attachment: attachments != null && mediaAttachmentId.isNotEmpty
        ? AnnotationAttachment.fromJson(
            mediaAttachmentId,
            attachments[mediaAttachmentId],
          )
        : null,
  );
}