loadMoreReplies method

Future<void> loadMoreReplies(
  1. String commentId
)

Implementation

Future<void> loadMoreReplies(String commentId) async {
  final index = _comments.indexWhere((c) => c.id == commentId);
  if (index == -1) return;
  final nextPage = (_replyPageByComment[commentId] ?? 1) + 1;
  final more = await controller.getReplies(commentId, nextPage);
  if (more.isEmpty) return;
  _replyPageByComment[commentId] = nextPage;
  final c = _comments[index];
  _comments[index] = c.copyWith(replies: [...c.replies, ...more]);
  notifyListeners();
}