Skip to main content

List Item

CometChatListItem contains one to three lines of text optionally flanked by icons or other widgets, such as CometChatAvatar, CometChatDate or Text. CometChatAvatar will always be shown in the leading view therefore either one among the avatarURL or avatarName must be provided. The icons (or other widgets) for the list item are defined with the tailView parameter. The first line of text is optional and is specified with title. The value of subtitle is also optional, will occupy the space allocated for an additional line of text or some other widget.

Properties

PropertiesTypeDescription
avatarURLStringsets image url to be shown in avatar in the leading view
avatarNameStringsets name to be shown in avatar in the leading view if avatarURL is not available
idStringunique id for the widget
statusIndicatorColorColorsets color of the status indicator
statusIndicatorIconWidgetsets icon of the status indicator
titleStringsets the title to display
subtitleViewWidgetsets custom subtitle below the title
tailViewWidgetsets the trailing widget, can be a Text, CometChatDate or CometChatBadge
optionsList<CometChatOption>list of option available for the list item
hideSeparatorboolused to hide the divider separating the list items
styleListItemStyleused to customize the appearance of this widget
avatarStyleAvatarStyleused to customise the Avatar shown in the leading view
statusIndicatorStyleStatusIndicatorStyleused to customise the status indicator
themeCometChatThemeused to set custom theme

ListItemStyle

ListItemStyle is the class containing attributes to customize appearance of this widget.

PropertiesTypeDescription
titleStyleTextStyleused to customise the appearance of the title
separatorColorColorused to set the color of the divider separating the list items
heightdoubleused to set height
widthdoubleused to set width
backgroundColorused to set the background color
gradientGradientused to set background gradient
borderBoxBorderused to set border
borderRadiusdoubleused to set border radius

Usage

User _user = User(
name: 'Kevin',
uid: 'UID233',
avatar: "https:__data-us.cometchat.io_assets_images_avatars_spiderman.png",
role: "test",
status: "online",
statusMessage: "This is now status"
);

StatusIndicatorUtils statusIndicatorUtils =StatusIndicatorUtils.getStatusIndicatorFromParams(
theme: cometChatTheme,
user: _user,
);

Color? backgroundColor = statusIndicatorUtils.statusIndicatorColor;
Widget? icon = statusIndicatorUtils.icon;

CometChatListItem(
avatarName: _user.name,
avatarURL: _user.avatar,
title: _user.name,
statusIndicatorColor: backgroundColor,
statusIndicatorIcon: icon
)