LMFeedIcon
LMFeedIcon
is a versatile widget designed for displaying icons within the Flutter UI library. It supports three types of icons: Material Design icons, PNG images, and SVG images. Additionally, it offers extensive customization options through the LMFeedIconStyle
class.
The LMFeedIcon
widget provides a unified interface for displaying icons of various formats, including Material Design icons, PNG images, and SVG images. It allows developers to easily incorporate icons into their user interfaces while maintaining a consistent appearance and behavior throughout the application.
Properties
type
(LMFeedIconType)
An enum value that specifies the type of icon to be displayed. The available options are:
LMFeedIconType.icon
: For Material Design iconsLMFeedIconType.svg
: For SVG imagesLMFeedIconType.webp
: For PNG imagesicon
(IconData)
The IconData
representing the Material Design icon to be displayed. This property is required when type
is set to LMFeedIconType.icon
.
assetPath
(String)
The asset path for the PNG or SVG image to be displayed. This property is required when type
is set to LMFeedIconType.webp
or LMFeedIconType.svg
.
style
(LMFeedIconStyle)
An optional style class that allows customization of the icon's appearance, such as color, size, background color, padding, and more.
Styling
The LMFeedIconStyle
class provides a way to define the visual style of the icon. It includes properties for icon color, size, background color, padding, border radius, and more.
Customization variables
Property | Type | Description | Required | Default |
---|---|---|---|---|
color | Color | Color of the icon (not applicable for PNG icons) | ||
size | double | Square size of the icon | 24.0 | |
boxSize | double | Square size of the box surrounding the icon | ||
boxBorder | double | Weight of the border around the box | ||
boxBorderRadius | double | Radius of the box around the icon | ||
boxPadding | double | Padding around the icon with respect to the box | 0.0 | |
backgroundColor | Color | Color of the box or background color of the icon | ||
fit | BoxFit | How the icon should be fit inside the box | BoxFit.contain |
Usage Example
LMFeedIcon(
type: LMFeedIconType.icon,
icon: Icons.favorite,
style: LMFeedIconStyle(
color: Colors.red,
size: 32,
boxSize: 48,
boxBorderRadius: 8,
backgroundColor: Colors.grey.withOpacity(0.2),
),
),
This example creates a LMFeedIcon
widget displaying a Material Design icon (Icons.favorite
). The icon is styled with a red color, a size of 32 pixels, and is placed inside a box with a size of 48 pixels, a border radius of 8 pixels, and a semi-transparent grey background color.