A powerful search interface for finding conversations and messages in real time
AI Agent Component Spec
{ "component": "CometChatSearch", "package": "cometchat_chat_uikit", "import": "import 'package:cometchat_chat_uikit/cometchat_chat_uikit.dart';", "description": "A powerful search interface that allows users to search across conversations and messages in real time with filters and customization options", "primaryOutput": { "prop": "onMessageClicked", "type": "void Function(BaseMessage message)" }, "props": { "data": { "user": { "type": "User?", "default": "null", "note": "User object for user message search" }, "group": { "type": "Group?", "default": "null", "note": "Group object for group message search" }, "searchFilters": { "type": "List<SearchFilter>?", "default": "null", "note": "List of filters to be shown in the search screen" }, "searchIn": { "type": "List<SearchScope>?", "default": "null", "note": "List of scopes to be shown in the search result" } }, "callbacks": { "onBack": "VoidCallback?", "onConversationClicked": "void Function(Conversation conversation)?", "onMessageClicked": "void Function(BaseMessage message)?", "onError": "OnError?", "onConversationsLoad": "OnLoad<Conversation>?", "onMessagesLoad": "OnLoad<BaseMessage>?", "onEmpty": "OnEmpty?" }, "visibility": { "usersStatusVisibility": { "type": "bool?", "default": "null" }, "receiptsVisibility": { "type": "bool?", "default": "null" }, "groupTypeVisibility": { "type": "bool?", "default": "null" } }, "viewSlots": { "loadingStateView": "WidgetBuilder?", "errorStateView": "WidgetBuilder?", "emptyStateView": "WidgetBuilder?", "initialStateView": "WidgetBuilder?", "conversationItemView": "Widget? Function(BuildContext, Conversation)?", "conversationTitleView": "Widget? Function(BuildContext, Conversation)?", "conversationLeadingView": "Widget? Function(BuildContext, Conversation)?", "conversationSubtitleView": "Widget? Function(BuildContext, Conversation)?", "conversationTailView": "Widget? Function(BuildContext, Conversation)?", "searchTextMessageView": "Widget? Function(BuildContext, TextMessage)?", "searchImageMessageView": "Widget? Function(BuildContext, MediaMessage)?", "searchVideoMessageView": "Widget? Function(BuildContext, MediaMessage)?", "searchFileMessageView": "Widget? Function(BuildContext, MediaMessage)?", "searchAudioMessageView": "Widget? Function(BuildContext, MediaMessage)?", "searchMessageLinkView": "Widget? Function(BuildContext, BaseMessage)?" }, "formatting": { "dateSeparatorFormatterCallback": { "type": "DateTimeFormatterCallback?", "default": "null" }, "timeSeparatorFormatterCallback": { "type": "DateTimeFormatterCallback?", "default": "null" } } }, "events": [], "sdkListeners": [], "compositionExample": { "description": "CometChatSearch can be used standalone or embedded within other screens", "components": ["CometChatConversations", "CometChatMessageList"], "flow": "User searches → Results displayed → User clicks result → Navigate to conversation/message" }, "types": { "SearchFilter": { "label": "String", "icon": "Widget?" }, "SearchScope": { "conversations": "bool", "messages": "bool" } }}
Where It Fits
CometChatSearch is a full-screen search experience that allows users to find messages, conversations, media, and more through an intuitive and filterable search interface. It can be embedded in multiple contexts — as part of the conversation list, message header, or as a standalone full-screen search experience.
Minimal Render
The simplest way to render CometChatSearch:
Dart
import 'package:cometchat_chat_uikit/cometchat_chat_uikit.dart';import 'package:flutter/material.dart';// Using Navigator to launch CometChatSearchNavigator.push( context, MaterialPageRoute(builder: (context) => CometChatSearch()));
Search within a specific user or group conversation:
Dart
// Search within a specific user's conversationCometChatSearch( user: user,)// Search within a specific group's conversationCometChatSearch( group: group,)
Actions and Events
Callback Props
Component-level callbacks that fire on specific user interactions:
Callback
Signature
Fires When
onConversationClicked
void Function(Conversation conversation)?
User clicks a conversation from search results
onMessageClicked
void Function(BaseMessage message)?
User clicks a message from search results
onBack
VoidCallback?
User clicks the back button
onError
OnError?
An error occurs in the component
onConversationsLoad
OnLoad<Conversation>?
Conversations are loaded
onMessagesLoad
OnLoad<BaseMessage>?
Messages are loaded
onEmpty
OnEmpty?
Search results are empty
Dart
CometChatSearch( onConversationClicked: (conversation) { // Navigate to the conversation print('Conversation clicked: ${conversation.conversationId}'); }, onMessageClicked: (message) { // Navigate to the message print('Message clicked: ${message.id}'); }, onBack: () { Navigator.pop(context); }, onError: (e) { print('Error: $e'); },)
Global UI Events
The CometChatSearch component does not produce any global UI events.
Custom View Slots
Customize the appearance of CometChatSearch by replacing default views with your own widgets.