CometChatConversations renders a scrollable list of recent conversations with real-time updates for new messages, typing indicators, read receipts, and user presence.
Where It Fits
CometChatConversations is a list component. It renders recent conversations and emits the selected Conversation via onItemTap. Wire it to CometChatMessageHeader, CometChatMessageList, and CometChatMessageComposer to build a standard chat layout.
- Dart
Quick Start
Using Navigator:- Dart
- Dart
CometChatUIKit.init(), a user logged in, and the UI Kit dependency added.
Filtering Conversations
Pass aConversationsRequestBuilder to control what loads:
- Dart
Filter Recipes
| Recipe | Builder property |
|---|---|
| Only user conversations | ..conversationType = "user" |
| Only group conversations | ..conversationType = "group" |
| Limit per page | ..limit = 10 |
| With tags | ..tags = ["vip"] and ..withTags = true |
| With user and group tags | ..withUserAndGroupTags = true |
Actions and Events
Callback Methods
onItemTap
Fires when a conversation row is tapped. Primary navigation hook.
- Dart
onItemLongPress
Fires when a conversation row is long-pressed. By default shows a delete overlay (when deleteConversationOptionVisibility is true).
- Dart
onBack
Fires when the user presses the back button in the app bar.
- Dart
onSelection
Fires when conversations are selected/deselected in multi-select mode.
- Dart
onError
Fires on internal errors (network failure, auth issue, SDK exception).
- Dart
onLoad
Fires when the list is successfully fetched and loaded.
- Dart
onEmpty
Fires when the list is empty after loading.
- Dart
Global Events
The component emits events viaCometChatConversationEvents that can be subscribed to from anywhere:
- Dart
SDK Events (Real-Time, Automatic)
The component listens to these SDK events internally. No manual setup needed.| SDK Listener | Internal behavior |
|---|---|
onTextMessageReceived / onMediaMessageReceived / onCustomMessageReceived | Moves conversation to top, updates last message and unread count |
onTypingStarted / onTypingEnded | Shows/hides typing indicator in subtitle |
onMessagesDelivered / onMessagesRead | Updates receipt indicators |
onUserOnline / onUserOffline | Updates presence status dot |
onGroupMemberJoined / onGroupMemberLeft / onGroupMemberKicked / onGroupMemberBanned | Updates group conversation metadata |
| Connection reconnected | Triggers silent refresh to sync missed messages |
Functionality
| Property | Type | Default | Description |
|---|---|---|---|
title | String? | null | Custom app bar title |
showBackButton | bool | false | Toggle back button |
hideAppbar | bool? | false | Toggle app bar visibility |
hideSearch | bool? | null | Toggle search bar |
searchReadOnly | bool | false | Make search bar read-only (tap opens custom search) |
deleteConversationOptionVisibility | bool? | true | Show delete option on long press |
groupTypeVisibility | bool? | true | Show group type icon on avatar |
usersStatusVisibility | bool? | true | Show online/offline status indicator |
receiptsVisibility | bool? | true | Show message receipts |
disableSoundForMessages | bool | false | Disable message sounds |
customSoundForMessages | String? | null | Custom notification sound asset path |
selectionMode | SelectionMode? | null | Enable selection mode (single or multiple) |
Custom View Slots
Leading View
Replace the avatar / left section.- Dart
Title View
Replace the name / title text.- Dart
Subtitle View
Replace the last message preview.- Dart
Trailing View
Replace the timestamp / badge / right section.- Dart
List Item View
Replace the entire list item row.- Dart
State Views
- Dart
Menu Options
- Dart
Common Patterns
Minimal list — hide all chrome
- Dart
Users-only conversations
- Dart
Custom date formatting
- Dart
Advanced
BLoC Access
Provide a customConversationsBloc to override behavior:
- Dart
Extending ConversationsBloc
ConversationsBloc uses the ListBase<Conversation> mixin with override hooks for custom list behavior:
- Dart
ListBase override hooks (onItemAdded, onItemRemoved, onItemUpdated, onListCleared, onListReplaced), see BLoC & Data — ListBase Hooks.
Public BLoC Events
| Event | Description |
|---|---|
LoadConversations({silent}) | Load initial conversations. silent: true keeps existing list visible during refresh. |
LoadMoreConversations() | Load next page (pagination) |
RefreshConversations() | Refresh the list |
DeleteConversation(conversationId) | Delete via SDK and remove from list |
RemoveConversation(conversationId) | Remove from list without SDK call |
SetActiveConversation(conversationId) | Mark as active (suppresses unread count) |
UpdateConversation(conversationId, updatedConversation) | Update with modified data |
ResetUnreadCount(conversationId) | Reset unread count to 0 |
Public BLoC Methods
| Method | Returns | Description |
|---|---|---|
getTypingNotifier(conversationId) | ValueNotifier<List<TypingIndicator>> | Per-conversation typing notifier for isolated rebuilds |
getTypingIndicators(conversationId) | List<TypingIndicator> | Current typing indicators for a conversation |
Route Observer
Pass aRouteObserver to freeze rebuilds when another screen is pushed on top (prevents expensive rebuilds during keyboard animation):
- Dart
Style
- Dart
Style Properties
| Property | Description |
|---|---|
backgroundColor | List background color |
avatarStyle | Avatar appearance |
badgeStyle | Unread badge appearance |
receiptStyle | Read receipt icons |
typingIndicatorStyle | Typing indicator text |
dateStyle | Timestamp appearance |
mentionsStyle | Mention highlight style |
deleteConversationDialogStyle | Delete confirmation dialog |
Next Steps
Users
Browse and search available users
Message List
Display messages for a conversation
Component Styling
Detailed styling reference
Message Template
Customize message bubble structure