Overview
TheCometChatSearch component is a powerful and customizable search interface that allows users to search across conversations and messages in real time. It supports a wide variety of filters, scopes, and customization options. CometChatSearch helps users find messages, conversations, media, and more through an intuitive and filterable search experience. It can be embedded in multiple contexts — as part of the conversation list, message header, or as a full-screen search experience.

Usage
Integration
You can launchCometChatSearch directly using Navigator.push, or you can define it as a widget within the build method of your State class.
1. Using Navigator to Launch CometChatSearch
- Dart
2. Embedding CometChatSearch as a Widget in the build Method
- Dart
Actions
Actions dictate how a widget functions. They are divided into two types: Predefined and User-defined. You can override either type, allowing you to tailor the behavior of the widget to fit your specific needs.1. onConversationClicked
onConversationClicked is triggered when you click on a Conversation from the search result. The onConversationClicked action doesn’t have a predefined behavior. You can override this action using the following code snippet.
- Dart
2. onMessageClicked
onMessageClicked is triggered when you click on a Message from the search result. The onMessageClicked action doesn’t have a predefined behavior. You can override this action using the following code snippet.
- Dart
3. onBack
OnBack is triggered when you click on the back button of the Message Header component. You can override this action using the following code snippet.
- Dart
4. onError
This action doesn’t change the behavior of the component but rather listens for any errors that occur in the Conversations component.- Dart
Filters
1. ConversationsRequestBuilder
You can set theConversationsRequestBuilder in the Search Component to filter the search result. You can modify the builder as per your specific requirements with multiple options available to know more refer to ConversationRequestBuilder.
- Dart
2. MessagesRequestBuilder
You can set theMessagesRequestBuilder in the Search Component to filter the search result. You can modify the builder as per your specific requirements with multiple options available to know more refer to MessagesRequestBuilder.
- Dart
Events
Events are emitted by a Component. By using event you can extend existing functionality. Being global events, they can be applied in multiple locations and are capable of being added or removed.
The CometChatSearch component does not produce any events.
Customization
To fit your app’s design requirements, you can customize the appearance of theCometChatSearch component. We provide exposed methods that allow you to modify the experience and behavior according to your specific needs.
Style
Using Style you can customize the look and feel of the component in your app, These parameters typically control elements such as the color, size, shape, and fonts used within the component.
- Dart
Functionality
These are a set of small functional customizations that allow you to fine-tune the overall experience of the component. With these, you can toggle the visibility of UI elements. Below is a list of customizations along with corresponding code snippetsCometChatMessageHeader Properties
Following is a list of customizations along with their corresponding code snippets:| Property | Data Type | Description |
|---|---|---|
user | User? | Set User object, one is mandatory either user or group. |
group | Group? | Set Group object, one is mandatory either user or group. |
usersStatusVisibility | bool? | Controls visibility of status indicator shown if a user is online. |
groupTypeVisibility | bool? | Hide the group type icon which is visible on the group icon. |
initialStateView | WidgetBuilder? | Sets view fow initial state |
loadingStateView | WidgetBuilder? | Sets view fow loading state |
emptyStateView | WidgetBuilder? | Sets view fow empty state |
errorStateView | WidgetBuilder? | Sets view fow error state |
Advanced
For advanced-level customization, you can set custom views to the component. This lets you tailor each aspect of the component to fit your exact needs and application aesthetics. You can create and define your views, layouts, and UI elements and then incorporate those into the component.conversationItemView
With this function, you can assign a custom list item view to an conversation in the search result. For more information, refer to the listItemView prop of theCometChatConversations component.
conversationLeadingView
With this function, you can assign a custom leading view to an conversation in the search result. For more information, refer to the leadingView prop of theCometChatConversations component.
conversationTitleView
With this function, you can assign a custom title view of an conversation in the search result. For more information, refer to the titleview prop of theCometChatConversations component.
conversationSubtitleView
With this function, you can assign a custom subtitle view to an conversation in the search result. For more information, refer to the subtitleview prop of theCometChatConversations component.
conversationTailView
With this function, you can assign a custom tail view to an conversation in the search result. For more information, refer to the trailingview prop of theCometChatConversations component.
MessageItemView
With message item view functions, you can assign custom views to different types of messages in the search result. Here’s how you can override the default message item view with a custom one for text messages:- Dart

| Function | Message Type |
|---|---|
searchTextMessageView | Text Message |
searchImageMessageView | Image Message |
searchAudioMessageView | Audio Message |
searchFileMessageView | Document Message |
searchMessageLinkView | Link Message |
searchVideoMessageView | Video Message |
DateTime Formatters
dateSeparatorFormatterCallback
You can modify the date pattern of the chat history date separator to your requirement usingdateSeparatorFormatterCallback. This method accepts a function with a return type String. Inside the function, you can create your own pattern and return it as a String.