fromJson method

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

Implementation

@override
UEmbedRecordWithMediaMedia fromJson(Map<String, dynamic> json) {
  try {
    if (EmbedImages.validate(json)) {
      return UEmbedRecordWithMediaMedia.embedImages(
        data: const EmbedImagesConverter().fromJson(json),
      );
    }
    if (EmbedVideo.validate(json)) {
      return UEmbedRecordWithMediaMedia.embedVideo(
        data: const EmbedVideoConverter().fromJson(json),
      );
    }
    if (EmbedExternal.validate(json)) {
      return UEmbedRecordWithMediaMedia.embedExternal(
        data: const EmbedExternalConverter().fromJson(json),
      );
    }

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