getComments method

Future<CommentsList?> getComments(
  1. Video video
)

Returns a List<Comment> containing the first batch of comments or null if the video has comments disabled. You can use CommentsList.nextPage() to get the next batch of comments.

WARNING: As of v2.2.0 this is broken due to yt updates.

Implementation

Future<CommentsList?> getComments(Video video) async {
  if (video.watchPage == null) {
    return null;
  }

  final page = await re.CommentsClient.get(_httpClient, video);

  if (page == null || page.comments == null) {
    return null;
  }

  return CommentsList(
    page.comments!
        .map(
          (e) => Comment(
            e.author,
            ChannelId(e.channelId),
            e.text,
            e.likeCount ?? 0,
            e.publishTime,
            e.repliesCount ?? 0,
            e.isHearted,
            e.continuation,
          ),
        )
        .toList(growable: false),
    page.getCommentsCount(),
    page,
    _httpClient,
  );
}