fromJson method

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

Implementation

@override
UFeedGetPostThreadThread fromJson(Map<String, dynamic> json) {
  if (ThreadViewPost.validate(json)) {
    return UFeedGetPostThreadThread.threadViewPost(
      data: const ThreadViewPostConverter().fromJson(json),
    );
  }
  if (NotFoundPost.validate(json)) {
    return UFeedGetPostThreadThread.notFoundPost(
      data: const NotFoundPostConverter().fromJson(json),
    );
  }
  if (BlockedPost.validate(json)) {
    return UFeedGetPostThreadThread.blockedPost(
      data: const BlockedPostConverter().fromJson(json),
    );
  }

  // No known `$type` matched: preserve the payload verbatim as an unknown
  // variant. A payload whose `$type` *does* match a known ref but fails to
  // convert is intentionally left to throw, so malformed data surfaces
  // instead of being silently degraded to `.unknown`.
  return UFeedGetPostThreadThread.unknown(data: json);
}