Skip to main content

LMFeedPostContent

LMFeedPostContent is a widget that represents the content section of a post in a feed. It displays the text content of the post and provides options for expanding or collapsing long text, highlighting tags, and customizing the appearance of the text.


LMFeedPostContent

The LMFeedPostContent widget is a part of the likeminds_feed_flutter_ui package. It is designed to be used within an LMFeedPostWidget to display the text content of a post in a consistent and customizable manner.

Properties

  • text (String)

The text content of the post. This is an optional parameter. If not provided, the text will be obtained from the InheritedPostProvider.

  • onTagTap (Function(String))

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

  • expanded (bool)

A flag to control whether the text should be initially expanded or collapsed. This is an optional parameter with a default value of false.

  • style (LMFeedPostContentStyle)

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

Styling

The LMFeedPostContentStyle class allows you to customize the appearance of the LMFeedPostContent.

Customization variables

PropertyTypeDescriptionRequiredDefault
textStyleTextStyleThe text style for the post content.
linkStyleTextStyleThe text style for links and tags in the post content.
expandTextStyleTextStyleThe text style for the "see more" text when the content is collapsed.
textAlignTextAlignThe alignment of the text content.
expandTextStringThe text to display for expanding the collapsed content."see more"
animationboolWhether to apply animation when expanding or collapsing the content.true
visibleLinesintThe number of lines to show when the content is collapsed.4
widthdoubleThe width of the post content container.
heightdoubleThe height of the post content container.
paddingEdgeInsetsThe padding of the post content container.
marginEdgeInsetsThe margin of the post content container.

You can create an instance of LMFeedPostContentStyle and pass it to the LMFeedPostContent to customize its appearance.

Usage Example

LMFeedPostContent(
text: "This is a sample post. Lorem ipsum dolor sit amet, consectetur adipiscing elit. Sed euismod, a sit amet aliquam lacinia, nisl nisl aliquam nisl, nec aliquam nisl nisl sit amet nisl.",
onTagTap: (tag) {
// Handle tag tap
print("Tapped tag: $tag");
},
expanded: false,
style: LMFeedPostContentStyle(
textStyle: TextStyle(
color: Colors.black,
fontSize: 16,
fontWeight: FontWeight.normal,
),
linkStyle: TextStyle(
color: Colors.blue,
fontSize: 16,
fontWeight: FontWeight.bold,
),
expandTextStyle: TextStyle(
color: Colors.grey,
fontSize: 14,
fontWeight: FontWeight.normal,
),
textAlign: TextAlign.left,
expandText: "Read more",
animation: true,
visibleLines: 3,
padding: EdgeInsets.all(16),
),
)

In this example, an LMFeedPostContent is created with a sample text content. The onTagTap callback is used to handle taps on tags within the content. The expanded flag is set to false to initially collapse the content. The appearance of the content is customized using LMFeedPostContentStyle, specifying the text styles, alignment, expand text, animation, visible lines, and padding.