LMFeedPostMedia
LMFeedPostMedia
is a widget that represents the media section of a post in a feed. It supports various types of media attachments, including images, videos, documents, and link previews. The widget provides a consistent and customizable way to display media attachments within a post.
The LMFeedPostMedia
widget is a part of the likeminds_feed_flutter_ui
package. It is designed to be used within an LMFeedPostWidget
to display media attachments associated with a post.
Properties
postId
(String
) - Required
The unique identifier of the post. This is a required parameter.
attachments
(List<LMAttachmentViewData>
) - Required
The list of media attachments associated with the post. This is a required parameter.
title
(LMFeedText
)
The title text widget for the media section. This is an optional parameter.
subtitle
(LMFeedText
)
The subtitle text widget for the media section. This is an optional parameter.
onError
(Function(String, StackTrace)
)
A callback function that is called when an error occurs while loading or displaying the media attachments. It receives the error message and stack trace as parameters. This is an optional parameter.
onMediaTap
(VoidCallback
)
A callback function that is called when a media attachment is tapped. This is an optional parameter.
style
(LMFeedPostMediaStyle
)
An instance of LMFeedPostMediaStyle
to customize the appearance of the media section. This is an optional parameter.
Styling
The LMFeedPostMediaStyle
class allows you to customize the appearance of different types of media attachments within the LMFeedPostMedia
widget.
Customization variables
Property | Type | Description | Required |
---|---|---|---|
videoStyle | LMFeedPostVideoStyle | The style configuration for video attachments. | Yes |
imageStyle | LMFeedPostImageStyle | The style configuration for image attachments. | Yes |
documentStyle | LMFeedPostDocumentStyle | The style configuration for document attachments. | Yes |
linkStyle | LMFeedPostLinkPreviewStyle | The style configuration for link preview attachments. | Yes |
pollStyle | LMFeedPollStyle | The style configuration for poll widget. | No |
carouselStyle | LMFeedPostCarouselStyle | The style configuration for carousel-style media attachments. | Yes |
You can create an instance of LMFeedPostMediaStyle
and pass it to the LMFeedPostMedia
widget to customize the appearance of media attachments.
Usage Example
LMFeedPostMedia(
postId: "post123",
attachments: [
LMAttachmentViewData(
attachmentType: 1,
attachmentMeta: LMAttachmentMeta(
url: "https://example.com/image.jpg",
width: 800,
height: 600,
),
),
LMAttachmentViewData(
attachmentType: 2,
attachmentMeta: LMAttachmentMeta(
url: "https://example.com/video.mp4",
duration: 120,
),
),
],
title: LMFeedText(text: "Media Attachments"),
subtitle: LMFeedText(text: "Images and Videos"),
onError: (error, stackTrace) {
// Handle error
print("Error: $error");
},
onMediaTap: () {
// Handle media tap
print("Media tapped");
},
style: LMFeedPostMediaStyle(
videoStyle: LMFeedPostVideoStyle(
// Customize video style
),
imageStyle: LMFeedPostImageStyle(
// Customize image style
),
documentStyle: LMFeedPostDocumentStyle(
// Customize document style
),
linkStyle: LMFeedPostLinkPreviewStyle(
// Customize link preview style
),
carouselStyle: LMFeedPostCarouselStyle(
// Customize carousel style
),
),
)
In this example, an LMFeedPostMedia
widget is created with a postId
and a list of attachments
. The title
and subtitle
properties are used to provide additional information about the media section. The onError
and onMediaTap
callbacks are used to handle errors and media tap events, respectively. The style
property is used to customize the appearance of different types of media attachments using the LMFeedPostMediaStyle
class.