Skip to main content

Overview

MessageList is a Composite Widget that displays a list of messages and effectively manages real-time operations. It includes various types of messages such as Text Messages, Media Messages, Stickers, and more. MessageList is primarily a list of the base widget MessageBubble. The MessageBubble Widget is utilized to create different types of chat bubbles depending on the message type.
Image

Usage

Integration

You can launch CometChatMessageList 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 CometChatMessageList
2. Embedding CometChatMessageList as a Widget in the build Method

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. onThreadRepliesClick
onThreadRepliesClick is triggered when you click on the threaded message bubble. The onThreadRepliesClick action doesn’t have a predefined behavior. You can override this action using the following code snippet.

2. onError
You can customize this behavior by using the provided code snippet to override the onError and improve error handling.

3. onReactionTap
The listener to be set for reacting to a message.Pass a non-null instance of onReactionTap to enable it.

Filters

You can adjust the MessagesRequestBuilder in the MessageList Widget to customize your message list. Numerous options are available to alter the builder to meet your specific needs. For additional details on MessagesRequestBuilder, please visit MessagesRequestBuilder. In the example below, we are applying a filter to the messages based on a search substring and for a specific user. This means that only messages that contain the search term and are associated with the specified user will be displayed
The following parameters in messageRequestBuilder will always be altered inside the message list
  1. UID
  2. GUID
  3. types
  4. categories

Events

Events are emitted by a Widget. 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 MessageList Widget does not emit any events of its own.

Customization

To fit your app’s design requirements, you can customize the appearance of the conversation widget. 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 widget in your app, These parameters typically control elements such as the color, size, shape, and fonts used within the widget.
1. MessageList Style
You can set the messageListStyle to the CometChatMessageList Widget to customize the styling.
Image
List of properties exposed by CometChatMessageList
2. Avatar Style
To apply customized styles to the Avatar widget in the CometChatGroups widget, you can use the following code snippet. For further insights on Avatar Styles refer

Functionality

These are a set of small functional customizations that allow you to fine-tune the overall experience of the widget. With these, you can change text, set custom icons, and toggle the visibility of UI elements.
Image
Image
Below is a list of customizations along with corresponding code snippets

Advance

For advanced-level customization, you can set custom views to the widget. This lets you tailor each aspect of the widget to fit your exact needs and application aesthetics. You can create and define your own widget and then incorporate those into the widget.

Template

CometChatMessageTemplate is a pre-defined structure for creating message views that can be used as a starting point or blueprint for creating message views often known as message bubbles. For more information, you can refer to CometChatMessageTemplate. You can set message Templates to MessageList by using the following code snippet
Example Here is the complete example for reference:
getTemplate()
Image

DateSeparatorPattern

You can modify the date pattern of the message list date separator to your requirement using setDateSeparatorPattern(). 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.
Example Here is the complete example for reference:
Image

SetDatePattern

You can modify the date pattern to your requirement using .setDatePattern. 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.
Example Here is the complete example for reference:
Image

ErrorStateView

You can set a custom ErrorStateView using errorStateView to match the error UI of your app.
widget
Here is the complete example for reference: Example
Image

LoadingStateView

You can set a custom loader widget using loadingStateView to match the loading UI of your app.
widget
Here is the complete example for reference: Example
main.dart
Image

EmptyStateView

You can set a custom EmptyStateView using emptyStateView to match the error widget of your app.
widget
Here is the complete example for reference: Example
main.dart

TextFormatters

Assigns the list of text formatters. If the provided list is not null, it sets the list. Otherwise, it assigns the default text formatters retrieved from the data source. To configure the existing Mentions look and feel check out MentionsFormatter Guide Here is the complete example for reference:
Image

Configuration

Configurations offer the ability to customize the properties of each widget within a Composite Widget.

MessageInformation

From the MessageList, you can navigate to the MesssageInformation widget as shown in the image. If you wish to modify the properties of the MesssageInformation Widget, you can use the MessageInformationConfiguration object.
Example
Image