fromJson method

  1. @override
UPostViewEmbed fromJson(
  1. Map<String, dynamic> json
)

Implementation

@override
UPostViewEmbed fromJson(Map<String, dynamic> json) {
  try {
    if (isImagesView(json)) {
      return UPostViewEmbed.imagesView(
        data: const ImagesViewConverter().fromJson(json),
      );
    }
    if (isVideoView(json)) {
      return UPostViewEmbed.videoView(
        data: const VideoViewConverter().fromJson(json),
      );
    }
    if (isExternalView(json)) {
      return UPostViewEmbed.externalView(
        data: const ExternalViewConverter().fromJson(json),
      );
    }
    if (isRecordView(json)) {
      return UPostViewEmbed.recordView(
        data: const RecordViewConverter().fromJson(json),
      );
    }
    if (isRecordWithMediaView(json)) {
      return UPostViewEmbed.recordWithMediaView(
        data: const RecordWithMediaViewConverter().fromJson(json),
      );
    }

    return UPostViewEmbed.unknown(data: json);
  } catch (_) {
    return UPostViewEmbed.unknown(data: json);
  }
}