Skip to main content

LMFeedButton

LMFeedButton is a customizable widget designed for displaying buttons within the Flutter UI library. It provides various styling options and supports both active and inactive states. The button can display text, icons, or a combination of both, and offers flexibility in their placement and appearance.


LMFeedButton

The LMFeedButton widget allows developers to create buttons with a consistent look and feel throughout their application. It supports different types of buttons, such as like, comment, share, save, and repost buttons, with predefined styles. Additionally, developers can customize the appearance and behavior of the button to suit their needs.

Properties

  • isActive (bool)

A required parameter that determines whether the button is in an active or inactive state.

  • style (LMFeedButtonStyle)

An optional style class that allows customization of the button's appearance, such as padding, background color, border, height, width, icon placement, and more.

  • text (LMFeedText)

An optional LMFeedText widget that represents the text to be displayed in the button.

  • onTap (Function())

A required callback function that is invoked when the button is tapped.

  • activeText (LMFeedText)

An optional LMFeedText widget that represents the text to be displayed in the button when it is in the active state.

  • onTextTap (VoidCallback)

An optional callback function that is invoked when the text in the button is tapped.

Styling

The LMFeedButtonStyle class provides a way to define the visual style of the button. It includes properties for padding, background color, border, border radius, height, width, icon placement, alignment, margin, and more.

Customization variables

PropertyTypeDescriptionRequiredDefault
paddingEdgeInsetsPadding of the buttonEdgeInsets.all(4)
backgroundColorColorBackground color of the buttonColors.transparent
borderBorderBorder of the button
borderRadiusdoubleBorder radius of the button container8.0
heightdoubleHeight of the button28.0
widthdoubleWidth of the button
placementLMFeedIconButtonPlacementPlacement of the icon in the buttonLMFeedIconButtonPlacement.start
mainAxisAlignmentMainAxisAlignmentMain axis alignment for button's icon and text
margindoubleMargin between the text and icon4.0
showTextboolWhether to show text in the buttontrue
iconLMFeedIconIcon to be displayed in the button
activeIconLMFeedIconIcon to be displayed in the active button state
textPaddingEdgeInsetsPadding for the text in the buttonEdgeInsets.zero

Usage Example

LMFeedButton(
isActive: true,
text: LMFeedText(
text: 'Like',
style: LMFeedTextStyle(
textStyle: TextStyle(
color: Colors.red,
fontWeight: FontWeight.bold,
),
),
),
activeText: LMFeedText(
text: 'Liked',
style: LMFeedTextStyle(
textStyle: TextStyle(
color: Colors.red,
fontWeight: FontWeight.bold,
),
),
),
style: LMFeedButtonStyle(
icon: LMFeedIcon(
type: LMFeedIconType.icon,
icon: Icons.favorite,
style: LMFeedIconStyle(
color: Colors.red,
),
),
activeIcon: LMFeedIcon(
type: LMFeedIconType.icon,
icon: Icons.favorite,
style: LMFeedIconStyle(
color: Colors.red,
),
),
),
onTap: () {
// Handle button tap
},
),

This example creates an active LMFeedButton with a "Like" text and a heart icon. The button is styled with a red color for both the text and the icon. When tapped, it triggers the onTap callback function, allowing you to handle the button's action.