Skip to main content

LMFeedDocument

LMFeedDocument is a widget that displays a document preview within a feed post. It shows the document's title, file type, and size. The widget provides customization options for styling the document preview and handling tap events.


LMFeedDocument

The LMFeedDocument widget is part of the likeminds_feed_flutter_ui package. It is designed to be used within an LMFeedPostWidget to display document previews associated with a post.

Properties

  • onTap (Function())

A callback function that is invoked when the document preview is tapped. This is an optional parameter.

  • documentFile (File)

The file object representing the document. Either documentFile or documentUrl must be provided.

  • documentUrl (String)

The URL of the document. Either documentFile or documentUrl must be provided.

  • type (String)

The file type of the document. This is an optional parameter with a default value of 'pdf'.

  • size (String)

The size of the document. This is an optional parameter.

  • title (LMFeedText)

A custom title text widget for the document preview. This is an optional parameter.

  • subtitle (LMFeedText)

A custom subtitle text widget for the document preview. This is an optional parameter.

  • onRemove (Function)

A callback function that is invoked when the remove button is tapped. This is an optional parameter.

  • style (LMFeedPostDocumentStyle)

The style configuration for the document preview. It allows customization of the document preview's appearance and behavior. This is an optional parameter.

Styling

The LMFeedPostDocumentStyle class allows you to customize the appearance and behavior of the LMFeedDocument widget.

Customization variables

PropertyTypeDescriptionRequiredDefault
heightdoubleThe height of the document preview container.72
widthdoubleThe width of the document preview container.Screen width - 40
borderRadiusdoubleThe border radius of the document preview container.8
borderSizedoubleThe border size of the document preview container.1
borderColorColorThe border color of the document preview container.Colors.grey
textColorColorThe color of the text in the document preview.Colors.grey.shade700
documentIconWidgetThe icon widget representing the document type.PDF icon
removeIconLMFeedIconThe icon widget for the remove button.Close icon
showBorderboolWhether to show the border around the document preview container.true
backgroundColorColorThe background color of the document preview container.
titleStyleLMFeedTextStyleThe text style for the document title.
subtitleStyleLMFeedTextStyleThe text style for the document subtitle.
paddingEdgeInsetsThe padding of the document preview container.16
marginEdgeInsetsThe margin of the document preview container.Vertical padding of 8

You can create an instance of LMFeedPostDocumentStyle and pass it to the LMFeedDocument widget to customize its appearance and behavior.

Usage Example

LMFeedDocument(
documentUrl: 'https://example.com/document.pdf',
type: 'pdf',
size: '2.5 MB',
onTap: () {
// Handle document tap
},
title: LMFeedText(
text: 'Example Document',
style: LMFeedTextStyle(
textStyle: TextStyle(
color: Colors.black,
fontSize: 16,
fontWeight: FontWeight.bold,
),
),
),
subtitle: LMFeedText(
text: 'PDF · 2.5 MB',
style: LMFeedTextStyle(
textStyle: TextStyle(
color: Colors.grey,
fontSize: 14,
),
),
),
onRemove: () {
// Handle remove button tap
},
style: LMFeedPostDocumentStyle(
height: 80,
width: 300,
borderRadius: 12,
borderSize: 2,
borderColor: Colors.blue,
textColor: Colors.black,
documentIcon: Icon(Icons.picture_as_pdf, color: Colors.red),
removeIcon: LMFeedIcon(
type: LMFeedIconType.icon,
icon: Icons.delete,
style: LMFeedIconStyle(color: Colors.red),
),
backgroundColor: Colors.white,
titleStyle: LMFeedTextStyle(
textStyle: TextStyle(
color: Colors.black,
fontSize: 16,
fontWeight: FontWeight.bold,
),
),
subtitleStyle: LMFeedTextStyle(
textStyle: TextStyle(
color: Colors.grey,
fontSize: 14,
),
),
padding: EdgeInsets.all(12),
margin: EdgeInsets.symmetric(vertical: 8),
),
)

In this example, an LMFeedDocument widget is created with the documentUrl property set to the URL of the document. The type and size properties specify the file type and size of the document. The onTap callback is provided to handle taps on the document preview. Custom title and subtitle widgets are used to display the document's title and subtitle. The onRemove callback is invoked when the remove button is tapped. The appearance of the document preview is customized using the LMFeedPostDocumentStyle class, specifying various properties such as height, width, border radius, border size, border color, text color, document icon, remove icon, background color, title style, subtitle style, padding, and margin.