Skip to main content

LMFeedPostWidget

LMFeedPostWidget is a highly customizable widget designed to display posts on a feed in a Flutter application. It provides a flexible and modular structure, allowing you to customize various components such as the header, footer, menu, media, and content. This widget is part of the likeminds_feed_flutter_ui library.


LMFeedPostWidget

The LMFeedPostWidget is a stateful widget that displays a post on the feed. It takes a LMPostViewData object, which represents the data for the post, and a LMUserViewData object, which represents the user associated with the post. The widget also accepts various optional parameters to customize its appearance and behavior, such as header, footer, menu, media, and content instances.

Properties

  • post (LMPostViewData) - Required

The data for the post to be displayed. This is a required parameter.

  • user (LMUserViewData) - Required

The data for the user associated with the post. This is a required parameter.

  • topics (List<LMTopicViewData>) - Required

A list of topics associated with the post. This is a required parameter.

  • isFeed (bool) - Required

A flag indicating whether the post is being displayed in a feed or not. This is a required parameter.

  • onPostTap (LMFeedOnPostTap?)

A callback function that is called when the post is tapped. This is an optional parameter.

  • onTagTap (Function(String)?)

A callback function that is called when a tag in the post content is tapped. This is an optional parameter.

  • onLikeTap (Function(bool isLiked)?)

A callback function that is called when the like button is tapped. This is an optional parameter.

  • onPinTap (Function(bool isPinned)?)

A callback function that is called when the pin button is tapped. This is an optional parameter.

  • onSaveTap (Function(bool isSaved)?)

A callback function that is called when the save button is tapped. This is an optional parameter.

  • childrenSpacing (double?)

The spacing between the children widgets. This is an optional parameter.

An instance of LMFeedPostHeader to be used as the header of the post. This is an optional parameter.

An instance of LMFeedPostFooter to be used as the footer of the post. This is an optional parameter.

An instance of LMFeedMenu to be used as the menu for the post. This is an optional parameter.

An instance of LMFeedPostContent to be used as the content of the post. This is an optional parameter.

An instance of LMFeedPostMedia to be used as the media for the post. This is an optional parameter.

An instance of LMFeedPostTopic to be used as the topic widget for the post. This is an optional parameter.

  • headerBuilder (LMFeedPostHeaderBuilder?)

A function that builds the header of the post. This is an optional parameter.

  • contentBuilder (LMFeedPostContentBuilder?)

A function that builds the content of the post. This is an optional parameter.

  • topicBuilder (LMFeedPostTopicBuilder?)

A function that builds the topic widget for the post. This is an optional parameter.

  • menuBuilder (LMFeedPostMenuBuilder?)

A function that builds the menu for the post. This is an optional parameter.

  • mediaBuilder (LMFeedPostMediaBuilder?)

A function that builds the media for the post. This is an optional parameter.

  • footerBuilder (LMFeedPostFooterBuilder?)

A function that builds the footer of the post. This is an optional parameter.

An instance of LMFeedPostStyle to customize the appearance of the post. This is an optional parameter.

  • onMediaTap (VoidCallback?)

A callback function that is called when the media is tapped. This is an optional parameter.

  • activityHeader (Widget?)

A widget to be displayed above the post header. This is an optional parameter.

  • disposeVideoPlayerOnInActive (VoidCallback?)

A callback function that is called when the widget is disposed, typically used to dispose of video players or other resources. This is an optional parameter.

Styling

The LMFeedPostStyle class allows you to customize the appearance of the LMFeedPostWidget.

Customization variables

PropertyTypeDescriptionRequiredDefault
boxShadowList<BoxShadow>The shadow to be applied to the post container
borderRadiusBorderRadiusGeometryThe border radius of the post container
paddingEdgeInsetsGeometryThe padding of the post container
marginEdgeInsetsGeometryThe margin of the post container
borderBoxBorderThe border of the post container
backgroundColorColorThe background color of the post container
likesListTypeLMFeedPostLikesListViewTypeThe type of view for the post's likes list
deleteSheetTypeLMFeedPostDeleteViewTypeThe type of view for the post's delete sheet

You can create an instance of LMFeedPostStyle and pass it to the LMFeedPostWidget to customize its appearance.

Usage Example

LMFeedPostWidget(
post: post,
user: user,
topics: topics,
isFeed: true,
onPostTap: (context, post) {
// Handle post tap
},
onTagTap: (tag) {
// Handle tag tap
},
onLikeTap: (isLiked) {
// Handle like tap
},
// Builds Post Header including user profile picture, name and menu
header: LMFeedPostHeader(
user: user,
postViewData: post,
),
content: LMFeedPostContent(
onTagTap: (tag) {
// Handle tag tap in content
},
),
footer: LMFeedPostFooter(
post: post,
onLikeTap: (isLiked) {
// Handle like tap in footer
},
),
style: LMFeedPostStyle(
borderRadius: BorderRadius.circular(8),
padding: const EdgeInsets.all(16),
),
);

This example creates a LMFeedPostWidget with a custom header, content, and footer. It also handles various tap events such as post tap, tag tap, and like tap. The appearance of the post is customized using LMFeedPostStyle.