AI Integration Quick Reference
AI Integration Quick Reference
CometChatMessageList renders a scrollable list of messages for a conversation with real-time updates for new messages, edits, deletions, reactions, and threaded replies.
Where It Fits
CometChatMessageList is a message display component. It requires either a User or Group object to fetch and render messages. Wire it with CometChatMessageHeader and CometChatMessageComposer to build a complete messaging layout.
- Dart
Quick Start
Using Navigator:- Dart
- Dart
CometChatUIKit.init(), a user logged in, and the UI Kit dependency added.
Filtering
Pass aMessagesRequestBuilder to control what loads:
- Dart
The following parameters in
MessagesRequestBuilder will always be altered inside the message list: UID, GUID, types, categories.Actions and Events
Callback Methods
onThreadRepliesClick
Fires when a user taps a threaded message bubble.
- Dart
onError
Fires on internal errors.
- Dart
onLoad
Fires when the list is successfully fetched and loaded.
- Dart
onEmpty
Fires when the list is empty after loading.
- Dart
onReactionClick
Fires when a reaction pill is tapped.
- Dart
onReactionLongPress
Fires when a reaction pill is long-pressed.
- Dart
SDK Events (Real-Time, Automatic)
The component listens to SDK message events internally. No manual setup needed.Functionality
* One of
user or group is required.
Custom View Slots
Header View
Custom view displayed at the top of the message list.- Dart
Footer View
Custom view displayed at the bottom of the message list.- Dart
State Views
- Dart
Text Formatters (Mentions)
- Dart
Message Templates
Override or extend message bubble rendering:- Dart
Multiple Attachments
A media message carrying several attachments renders with a dedicated per-type bubble: a media grid for images and videos, inline player rows for audio files, and a connected card stack for documents.
Tapping any image/video cell opens the full-screen media viewer, paged across the message’s image, video and audio attachments.
A voice note always renders as the classic single audio bubble, whatever the flag below — it is single by nature. Only picked audio files use the multi-attachment bubble.
image message and a file message: the photos render as a grid, the PDF as a card. They share a batchId and group as described below.
Grouping
Messages produced by one send sharebatchId, batchIndex and batchSize metadata, and the list presents them as one block:
- the avatar and sender name appear on the first message only
- the timestamp and receipt appear on the last message only
- reactions stay attached to their individual message
- the caption rides on the last message of the batch
Enable or disable
- Dart
false to render the classic single-attachment bubbles (CometChatImageBubble, CometChatVideoBubble, CometChatAudioBubble, CometChatFileBubble) instead. Those bubbles are deprecated and remain only for that path.
You can also drive it per-template through AdditionalConfigurations:
- Dart
Styling
Each bubble has its own style class:
Where a property has an equivalent on the old singular bubble it keeps the same name (
playIconColor, titleTextStyle, backgroundColor…), so migrating is a rename of the class, not of every field. Grid-only knobs — tileBorderRadius, gridSpacing, overflowScrimColor, captionTextStyle, the duration chip and the “+N more” toggle — have no old counterpart.
- Dart
Message Option Visibility
Common Patterns
Thread replies view
- Dart
Jump to a specific message
- Dart
Start from unread messages
- Dart
Load last agent conversation
Resume the most recent AI agent conversation on start:- Dart
Flag / Report a message
Flag/report is available by default from the message long-press menu. Toggle its visibility and customize the dialog:- Dart
Pin or save a message
Available since v6.1.1 With the features enabled, the action menu offers Pin message / Unpin message and Save message / Unsave message, the label following the message’s current state. They are wired to the SDK’s Pin A Message and Save A Message APIs — no setup is needed:- The options appear on any sent, non-deleted message, thread replies included. They are withheld from deleted messages, messages not yet sent or still pending moderation, your own messages that moderation disapproved, and group action messages, and they hide themselves when
CometChat.isPinMessageEnabled()/CometChat.isSaveMessageEnabled()returnsfalse. - Pin permission is enforced by the server, not the UI Kit. The Pin / Unpin option is shown to every participant; a user who lacks permission gets a “You don’t have permission to perform this action.” toast when they tap it. Save has no role gate.
- All four actions apply immediately, without a confirmation, and show a toast (“Message pinned”, “Message saved”, …). Hitting a cap shows “You can pin up to N messages in this conversation.” or “You can save up to N messages.”, with N taken from the server’s error.
- A pinned message shows a pin glyph, and a message the user saved shows a bookmark glyph, before the bubble’s timestamp. The glyphs update live, including for pins made by other members and saves made on the user’s other devices.
hidePinMessageOption and hideUnpinMessageOption; save works the same way.
- Dart
Jump to a message
Available since v6.1.1goToMessageId is read once when the list mounts, so it cannot re-aim a list that is already on screen — the case you hit when a pinned or saved row is tapped and the conversation is already open.
CometChatMessageListController covers that. Create it in your State, pass it as controller, and call jumpToMessage: the list scrolls to the message and highlights it, fetching the page around it first when it is not loaded yet.
- Dart
false rather than throwing, and isAttached reports the current state.
Mark a message as unread
Expose the “Mark as Unread” option in the long-press menu:- Dart
Advanced
BLoC Access
Provide a customMessageListBloc to override behavior:
- Dart
Extending MessageListBloc
MessageListBloc uses the ListBase<BaseMessage> mixin with override hooks:
- Dart
ListBase override hooks (onItemAdded, onItemRemoved, onItemUpdated, onListCleared, onListReplaced), see BLoC & Data — ListBase Hooks.
Public BLoC Events
Public BLoC Methods
O(1) Lookup Methods
ValueNotifier Accessors (Isolated Rebuilds)
MessageReceiptStatus Enum
Operations Stream
The BLoC exposes anoperationsStream consumed by CometChatAnimatedMessageList for smooth animations:
Style
- Dart
Next Steps
Message Header
Display user/group info in the app bar
Message Composer
Rich input for sending messages
Message Template
Customize message bubble structure
Component Styling
Detailed styling reference