Skip to main content

LMFeedCommentList

LMFeedCommentList is a widget designed to display a list of comments for a specific post in your Flutter application. It supports customization through various builder functions, allowing developers to tailor the look and behavior of the comment list. It handles pagination, error states, and empty views, making it ideal for use in feeds where user-generated content plays a central role.


Properties

  • postId (String)
    The ID of the post for which the comments are being displayed. This is a required parameter.

  • commentBuilder (LMFeedPostCommentBuilder?)
    A builder function to customize how individual comments are displayed.

  • commentSeparatorBuilder (Widget Function(BuildContext)?)
    A function to customize the separator between comments.

  • widgetSource (LMFeedWidgetSource)
    Specifies the source screen where the comment list is used (e.g., post detail).

  • noItemsFoundIndicatorBuilder (LMFeedContextWidgetBuilder?)
    A widget builder to display when no comments are available.

  • firstPageProgressIndicatorBuilder (LMFeedContextWidgetBuilder?)
    A builder for the first page loader when comments are being fetched.

  • newPageProgressIndicatorBuilder (LMFeedContextWidgetBuilder?)
    A builder for pagination loaders while fetching more comments.

  • noMoreItemsIndicatorBuilder (LMFeedContextWidgetBuilder?)
    A widget builder to display when there are no more comments to load.

  • newPageErrorIndicatorBuilder (LMFeedContextWidgetBuilder?)
    A builder for errors when loading new pages of comments.

  • firstPageErrorIndicatorBuilder (LMFeedContextWidgetBuilder?)
    A builder for errors when loading the first page of comments.

  • replyWidgetBuilder (LMFeedReplyWidgetBuilder?)
    A builder function to customize the reply widget below each comment.


copyWith (LMFeedCommentList)

The copyWith method creates a new instance of LMFeedCommentList with updated values, while retaining the current values for fields not overridden.

Usage

LMFeedCommentList copyWith({
String? postId,
LMFeedPostCommentBuilder? commentBuilder,
Widget Function(BuildContext)? commentSeparatorBuilder,
LMFeedWidgetSource? widgetSource,
LMFeedContextWidgetBuilder? noItemsFoundIndicatorBuilder,
LMFeedContextWidgetBuilder? firstPageProgressIndicatorBuilder,
LMFeedContextWidgetBuilder? newPageProgressIndicatorBuilder,
LMFeedContextWidgetBuilder? noMoreItemsIndicatorBuilder,
LMFeedContextWidgetBuilder? newPageErrorIndicatorBuilder,
LMFeedContextWidgetBuilder? firstPageErrorIndicatorBuilder,
LMFeedReplyWidgetBuilder? replyWidgetBuilder,
});

Usage Example

Below is an example demonstrating how to use LMFeedCommentList with custom builders for the comment separator, first page loader, and reply widget.

Code Example

LMFeedCommentList(
postId: "example-post-id",
commentBuilder: (context, commentWidget, postViewData) {
return Card(
margin: const EdgeInsets.all(8.0),
child: commentWidget, // Wraps each comment in a Card.
);
},
commentSeparatorBuilder: (context) => Divider(
thickness: 1,
color: Colors.grey[300],
),
firstPageProgressIndicatorBuilder: (context) => Center(
child: CircularProgressIndicator(),
),
noItemsFoundIndicatorBuilder: (context) => Center(
child: Text("No comments available."),
),
replyWidgetBuilder: (context, replyWidget) => Padding(
padding: const EdgeInsets.all(8.0),
child: replyWidget,
),
);