> ## Documentation Index
> Fetch the complete documentation index at: https://cometchat-22654f5b-docs-agent-in-group-react-v6.mintlify.site/llms.txt
> Use this file to discover all available pages before exploring further.

# Threaded Messages

> Threaded Messages — CometChat documentation.

## Overview

ThreadedMessages is a [Composite Widget](/ui-kit/flutter/v4/components-overview#composite-components) that displays all replies made to a particular message in a conversation. By default, the parent message will be displayed at the top, the message composer will be at the bottom and between them a message list will contain all replies.

<Tabs>
  <Tab title="Android">
    <img src="https://mintcdn.com/cometchat-22654f5b-docs-agent-in-group-react-v6/wITpHRGFWGJvJnmU/images/ecedc070-threaded_messages_overview_cometchat_screens-c3be7cfadd91b5d6d35362abbb78c2a3.png?fit=max&auto=format&n=wITpHRGFWGJvJnmU&q=85&s=7105f3e3ba690e5c6778475bd21ced54" alt="Image" width="4498" height="3121" data-path="images/ecedc070-threaded_messages_overview_cometchat_screens-c3be7cfadd91b5d6d35362abbb78c2a3.png" />
  </Tab>

  <Tab title="iOS">
    <img src="https://mintcdn.com/cometchat-22654f5b-docs-agent-in-group-react-v6/iIeExfBhmmmkVYg_/images/5a7b65b1-threaded_messages_overview_cometchat_screens-1d50f8528680bef2910c95b16aa00ba9.png?fit=max&auto=format&n=iIeExfBhmmmkVYg_&q=85&s=ece7735d256d18c4bbc7c6cfc918a257" alt="Image" width="4498" height="3121" data-path="images/5a7b65b1-threaded_messages_overview_cometchat_screens-1d50f8528680bef2910c95b16aa00ba9.png" />
  </Tab>
</Tabs>

ThreadedMessages is composed of the following widgets:

| Widget                                                 | Description                                                                                                     |
| ------------------------------------------------------ | --------------------------------------------------------------------------------------------------------------- |
| [MessageList](/ui-kit/flutter/v4/message-list)         | CometChatMessageList is a widget that displays a list of Messages                                               |
| [MessageComposer](/ui-kit/flutter/v4/message-composer) | CometChatMessageComposer is a widget that helps in writing and editing of messages and also sending attachments |

## Usage

### Integration

You can launch `CometChatThreadedMessages` 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 `CometChatThreadedMessages`

<Tabs>
  <Tab title="Dart">
    ```dart theme={null}
    Navigator.push(context, MaterialPageRoute(builder: (context) => CometChatThreadedMessages(loggedInUser: loggedInUser, parentMessage: parentMessage))); // Logged in user object and parent message object is required to launch this widget.
    ```
  </Tab>
</Tabs>

##### 2. Embedding `CometChatThreadedMessages` as a Widget in the build Method

<Tabs>
  <Tab title="Dart">
    ```dart theme={null}
    import 'package:cometchat_chat_uikit/cometchat_chat_uikit.dart';
    import 'package:flutter/material.dart';

    class ThreadMessages extends StatefulWidget {
      const ThreadMessages({super.key});

      @override
      State<ThreadMessages> createState() => _ThreadMessagesState();
    }

    class _ThreadMessagesState extends State<ThreadMessages> {

      @override
      Widget build(BuildContext context) {
        return Scaffold(
          body: SafeArea(
            child: CometChatThreadedMessages(loggedInUser: loggedInUser, parentMessage: parentMessage) // Logged in user object and parent message object is need.
          ),
        );
      }
    }
    ```
  </Tab>
</Tabs>

***

### Actions

[Actions](/ui-kit/flutter/v4/components-overview#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.

ThreadedMessages does not have its own actions. However, you can override the behavior of the ThreadedMessages widget by using the actions of its widgets, with the help of [Configurations](/ui-kit/flutter/v4/components-overview#configurations).

**Example**

In this example, we are overriding the `onThreadReplyClick` of the MessageList Widget using `MessageListConfiguration` and applying it to ThreadedMessages.

<Tabs>
  <Tab title="Dart">
    ```dart theme={null}
    CometChatThreadedMessages(
      loggedInUser: loggedInUser,
      parentMessage: parentMessage,
      messageListConfiguration: MessageListConfiguration(
        onThreadRepliesClick: (message, context, {bubbleView}) {
          // TODO("Not yet implemented")
        },
      ),
    )
    ```
  </Tab>
</Tabs>

***

### Filters

**Filters** allow you to customize the data displayed in a list within a Widget. You can filter the list based on your specific criteria, allowing for a more customized. Filters can be applied using RequestBuilders of Chat SDK.

ThreadedMessages does not have its own Filters. However, you can filter the messages list in ThreadedMessages Widget using [MessageListConfiguration](#configuration).

**Example**

In this example, we are filtering messages based on the `ParentMessageID` and searching for messages that contain the keyword "payment".

<Tabs>
  <Tab title="Dart">
    ```dart theme={null}
    CometChatThreadedMessages(
      loggedInUser: loggedInUser,
      parentMessage: parentMessage,
      messageListConfiguration: MessageListConfiguration(
          messagesRequestBuilder: MessagesRequestBuilder()
          ..limit = 30
          ..parentMessageId = parentMessage!.parentMessageId
          ..searchKeyword = "payment"
      ),
    )
    ```
  </Tab>
</Tabs>

***

### Events

[Events](/ui-kit/flutter/v4/components-overview#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. ThreadedMessage Style

To modify the styling, you can apply the ThreadedMessageStyle to the ThreadedMessage Widget using the `setStyle` method.

<Tabs>
  <Tab title="Dart">
    ```dart theme={null}
    CometChatThreadedMessages(
      loggedInUser: loggedInUser,
      parentMessage: parentMessage,
      threadedMessagesStyle: ThreadedMessageStyle(
        background: Color(0xFFE4EBF5),
        border: Border.all(width: 1, color: Colors.red),
        borderRadius: 10,
      )
    )
    ```
  </Tab>
</Tabs>

<Tabs>
  <Tab title="Android">
    <img src="https://mintcdn.com/cometchat-22654f5b-docs-agent-in-group-react-v6/-MogY9MW_bOB3epD/images/4d6dc777-threaded_messages_style_cometchat_screens-63ef307f7cfc5871fc6185e721796290.png?fit=max&auto=format&n=-MogY9MW_bOB3epD&q=85&s=020d66682057c51d2af87a8cdb534103" alt="Image" width="4498" height="3121" data-path="images/4d6dc777-threaded_messages_style_cometchat_screens-63ef307f7cfc5871fc6185e721796290.png" />
  </Tab>

  <Tab title="iOS">
    <img src="https://mintcdn.com/cometchat-22654f5b-docs-agent-in-group-react-v6/8U2-5SWHI94obVDJ/images/9ac78351-threaded_messages_style_cometchat_screens-e5d42d71c2048d59f9ef504187cb59c5.png?fit=max&auto=format&n=8U2-5SWHI94obVDJ&q=85&s=169dbf81214b6b910fca61511e8c817b" alt="Image" width="4498" height="3121" data-path="images/9ac78351-threaded_messages_style_cometchat_screens-e5d42d71c2048d59f9ef504187cb59c5.png" />
  </Tab>
</Tabs>

The following properties are exposed by `ThreadedMessagesStyle`:

| **Property**        | Description                                               | Code                          |
| ------------------- | --------------------------------------------------------- | ----------------------------- |
| **Background**      | Sets the background color of the threaded message style.  | `background: Color?`          |
| **Border**          | Sets the border properties of the threaded message style. | `border: Border?`             |
| **Border Radius**   | Sets the border radius of the threaded message style.     | `borderRadius: BorderRadius?` |
| **Close Icon Tint** | Sets the color for the close icon.                        | `closeIconTint: Color?`       |
| **Gradient**        | Sets the gradient applied to the threaded message style.  | `gradient: Gradient?`         |
| **Height**          | Sets the height of the threaded message style.            | `height: double?`             |
| **Title Style**     | Sets the text style for the title.                        | `titleStyle: TextStyle?`      |
| **Width**           | Sets the width of the threaded message style.             | `width: double?`              |

***

### 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.

<Tabs>
  <Tab title="Dart">
    ```dart theme={null}
    CometChatThreadedMessages(
      loggedInUser: loggedInUser,
      parentMessage: parentMessage,
      hideMessageComposer: true,
      title: "Your Title",
    )
    ```
  </Tab>
</Tabs>

<Tabs>
  <Tab title="Android">
    <img src="https://mintcdn.com/cometchat-22654f5b-docs-agent-in-group-react-v6/W03Ri2VAJwEo4Zob/images/7921b481-threaded_messages_functionality_cometchat_screens-7103f3e72d26d01dba89c9f2c0967a69.png?fit=max&auto=format&n=W03Ri2VAJwEo4Zob&q=85&s=bb8b8c4610d7c52573eba52345762593" alt="Image" width="4498" height="3121" data-path="images/7921b481-threaded_messages_functionality_cometchat_screens-7103f3e72d26d01dba89c9f2c0967a69.png" />
  </Tab>

  <Tab title="iOS">
    <img src="https://mintcdn.com/cometchat-22654f5b-docs-agent-in-group-react-v6/1dpm1fhJnD7O18Uv/images/ca3c4d2a-threaded_messages_functionality_cometchat_screens-c851393af6f0a189061c61ddc54ef364.png?fit=max&auto=format&n=1dpm1fhJnD7O18Uv&q=85&s=1855146b75fca72264eb11a0faecf0aa" alt="Image" width="4498" height="3121" data-path="images/ca3c4d2a-threaded_messages_functionality_cometchat_screens-c851393af6f0a189061c61ddc54ef364.png" />
  </Tab>
</Tabs>

Below is a list of customizations along with corresponding code snippets

| **Property**              | Description                                      | Code                         |
| ------------------------- | ------------------------------------------------ | ---------------------------- |
| **Close Icon**            | Sets the icon for closing the threaded messages. | `closeIcon: Icon?`           |
| **Hide Message Composer** | Hides the message composer.                      | `hideMessageComposer: bool?` |
| **Theme**                 | Sets the theme for the threaded messages.        | `theme: Theme?`              |
| **Title**                 | Sets the title for the threaded messages.        | `title: String?`             |

***

### Advanced

For advanced-level customization, you can set custom widgets 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 widgets, layouts, and UI elements and then incorporate those into the widget.

#### MessageBubbleView

By using `bubbleView`, You can set parent message buggle widget inside `CometChatThreadedMessages` Widget.

**Example**

Here is the complete example for reference:

<Tabs>
  <Tab title="Dart">
    ```dart theme={null}
    CometChatThreadedMessages(
      loggedInUser: loggedInUser,
      parentMessage: parentMessage,
      bubbleView: (BaseMessage baseMessage, BuildContext context) {
        return Container(
          width: MediaQuery.of(context).size.width,
          padding: const EdgeInsets.all(10),
          margin: const EdgeInsets.only(top: 10, bottom: 10),
          decoration: BoxDecoration(
            color: Colors.grey[300],
            borderRadius: BorderRadius.circular(10),
          ),
          child: Column(
            mainAxisAlignment: MainAxisAlignment.start,
            crossAxisAlignment: CrossAxisAlignment.start,
            children: [
              Text(baseMessage.sender!.name ?? "", style: const TextStyle(fontWeight: FontWeight.bold),),
              Text((baseMessage as TextMessage).text ?? "", style: const TextStyle(fontWeight: FontWeight.normal),),
            ],
          )
        );
      },
    )
    ```
  </Tab>
</Tabs>

<Tabs>
  <Tab title="Android">
    <img src="https://mintcdn.com/cometchat-22654f5b-docs-agent-in-group-react-v6/gyYKxTizhi5zqoIK/images/53e8c8ca-threaded_messages_bubble_view_cometchat_screens-dbc461b506dcefe3cce069b241cbd515.png?fit=max&auto=format&n=gyYKxTizhi5zqoIK&q=85&s=f7a8d2694f9a4f33c6f9fd5afebd5b41" alt="Image" width="4498" height="3121" data-path="images/53e8c8ca-threaded_messages_bubble_view_cometchat_screens-dbc461b506dcefe3cce069b241cbd515.png" />
  </Tab>

  <Tab title="iOS">
    <img src="https://mintcdn.com/cometchat-22654f5b-docs-agent-in-group-react-v6/hvldi1e9uY_02hWX/images/8a0c1244-threaded_messages_bubble_view_cometchat_screens-c778bca74e6a186e84d92cc8feaf3831.png?fit=max&auto=format&n=hvldi1e9uY_02hWX&q=85&s=b271c04f7e67015034bff2ed86f3d5a0" alt="Image" width="4498" height="3121" data-path="images/8a0c1244-threaded_messages_bubble_view_cometchat_screens-c778bca74e6a186e84d92cc8feaf3831.png" />
  </Tab>
</Tabs>

***

#### MessageActionView

By utilizing the `messageActionView` method, you can assign custom actions to the parent message bubble widget inside the `CometChatThreadedMessages` Widget.

**Example**

Here is the complete example for reference:

<Tabs>
  <Tab title="Dart">
    ```dart theme={null}
    CometChatThreadedMessages(
      loggedInUser: loggedInUser,
      parentMessage: parentMessage,
      messageActionView: (BaseMessage baseMessage, BuildContext context) {
        return Container(
          width: MediaQuery.of(context).size.width / 1.2,
          margin: const EdgeInsets.all(10),
          decoration: BoxDecoration(
            color: Color(0xFF6851D6),
            borderRadius: BorderRadius.circular(10),
            border: Border.all(width: 5, color: Color(0xFF6851D6)),
          ),
          child: const Center(
            child: Text("Your Custom Action View",
              style: TextStyle(color: Colors.white),),
          ),
        );
      },
    )
    ```
  </Tab>
</Tabs>

<Tabs>
  <Tab title="Android">
    <img src="https://mintcdn.com/cometchat-22654f5b-docs-agent-in-group-react-v6/-aV5rjAnFmfmGI_M/images/854e21f6-threaded_messages_action_view_cometchat_screens-7f88ee62a1538cddfa6da45c8eb28982.png?fit=max&auto=format&n=-aV5rjAnFmfmGI_M&q=85&s=941208cf74585f07be3f51ef5544d6c8" alt="Image" width="4498" height="3121" data-path="images/854e21f6-threaded_messages_action_view_cometchat_screens-7f88ee62a1538cddfa6da45c8eb28982.png" />
  </Tab>

  <Tab title="iOS">
    <img src="https://mintcdn.com/cometchat-22654f5b-docs-agent-in-group-react-v6/_EL7Vq6dx_iRWqWt/images/07942114-threaded_messages_action_view_cometchat_screens-0d30d7d0d3394b0a40ee33ea511157b3.png?fit=max&auto=format&n=_EL7Vq6dx_iRWqWt&q=85&s=bfbc17c47f5646333d596225063cc61e" alt="Image" width="4498" height="3121" data-path="images/07942114-threaded_messages_action_view_cometchat_screens-0d30d7d0d3394b0a40ee33ea511157b3.png" />
  </Tab>
</Tabs>

***

#### MessageListView

You can set your custom message list widget using the `messageListView` method. But keep in mind, by using this you will override the default message ListView functionality.

**Example**

Here is the complete example for reference:

<Tabs>
  <Tab title="Dart">
    ```dart theme={null}
    CometChatThreadedMessages(
      loggedInUser: loggedInUser,
      parentMessage: parentMessage,
      messageListView: (user, group, context, parentMessage) {
        return Container(
          width: MediaQuery.of(context).size.width / 1.2,
          margin: const EdgeInsets.all(10),
          decoration: BoxDecoration(
            color: Color(0xFF6851D6),
            borderRadius: BorderRadius.circular(10),
            border: Border.all(width: 5, color: Color(0xFF6851D6)),
          ),
          child: const Center(
            child: Text("Your Custom List View",
              style: TextStyle(color: Colors.white),),
          ),
        );
      },
    )
    ```
  </Tab>
</Tabs>

<Tabs>
  <Tab title="Android">
    <img src="https://mintcdn.com/cometchat-22654f5b-docs-agent-in-group-react-v6/RI0xrNuukR5gbXqh/images/d9a2e84b-threaded_messages_list_view_cometchat_screens-eab6b59c818d4404416b4f2c597f61c0.png?fit=max&auto=format&n=RI0xrNuukR5gbXqh&q=85&s=5326cde66b696fd10ae2c564c8aec53b" alt="Image" width="4498" height="3121" data-path="images/d9a2e84b-threaded_messages_list_view_cometchat_screens-eab6b59c818d4404416b4f2c597f61c0.png" />
  </Tab>

  <Tab title="iOS">
    <img src="https://mintcdn.com/cometchat-22654f5b-docs-agent-in-group-react-v6/VF5v8Yrr3_dtKi2l/images/239f882f-threaded_messages_list_view_cometchat_screens-910cae72acd25b5aae66faf6e884c528.png?fit=max&auto=format&n=VF5v8Yrr3_dtKi2l&q=85&s=6020b6958d087887a01200194a52fb98" alt="Image" width="4498" height="3121" data-path="images/239f882f-threaded_messages_list_view_cometchat_screens-910cae72acd25b5aae66faf6e884c528.png" />
  </Tab>
</Tabs>

***

#### MessageComposerView

You can set your custom Message Composer widget using the `messageComposerView` method. But keep in mind, by using this you will override the default message composer functionality.

**Example**

Here is the complete example for reference:

<Tabs>
  <Tab title="Dart">
    ```dart theme={null}
    CometChatThreadedMessages(
      loggedInUser: loggedInUser,
      parentMessage: parentMessage,
      messageComposerView: (user, group, context, parentMessage) {
        return Container(
          width: MediaQuery.of(context).size.width / 1.1,
          margin: const EdgeInsets.all(10),
          decoration: BoxDecoration(
            color: Color(0xFF6851D6),
            borderRadius: BorderRadius.circular(10),
            border: Border.all(width: 5, color: Color(0xFF6851D6)),
          ),
          child: Row(
            children: [
              const Expanded(
                child: TextField(
                  decoration: InputDecoration(
                    hintText: "Type a message",
                    border: InputBorder.none,
                    hintStyle: TextStyle(color: Colors.white),
                  ),
                ),
              ),
              IconButton(
                onPressed: () {
                  // TODO("Not yet implemented")
                },
                icon: const Icon(Icons.send, color: Colors.white),
              )
            ],
          )
        );
      },
    )
    ```
  </Tab>
</Tabs>

***

## Configuration

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

The ThreadedMessages is a Composite Widget, and it has a distinct set of configurations for each of its widgets as follows.

### MessageList

If you want to customize the properties of the [MessageList](/ui-kit/flutter/v4/message-list) Widget inside ThreadedMessages Widget, you need use the `MessageListConfiguration` object.

**Example**

Here is the complete example for reference:

<Tabs>
  <Tab title="Dart">
    ```dart theme={null}
    CometChatThreadedMessages(
      loggedInUser: loggedInUser,
      parentMessage: parentMessage,
      messageListConfiguration: MessageListConfiguration(
        alignment: ChatAlignment.leftAligned,
        messageListStyle: MessageListStyle(
          background: Color(0xFFE4EBF5),
          border: Border.all(width: 1, color: Colors.red),
          borderRadius: 10,
        ),
      ),
    )
    ```
  </Tab>
</Tabs>

<Tabs>
  <Tab title="Android">
    <img src="https://mintcdn.com/cometchat-22654f5b-docs-agent-in-group-react-v6/wITpHRGFWGJvJnmU/images/e9e02a6f-threaded_messages_list_item_config_cometchat_screens-3bf38251126d5538f47cff7f04e15f46.png?fit=max&auto=format&n=wITpHRGFWGJvJnmU&q=85&s=616d9260b651891b8b7ca9043361b189" alt="Image" width="4498" height="3121" data-path="images/e9e02a6f-threaded_messages_list_item_config_cometchat_screens-3bf38251126d5538f47cff7f04e15f46.png" />
  </Tab>

  <Tab title="iOS">
    <img src="https://mintcdn.com/cometchat-22654f5b-docs-agent-in-group-react-v6/fW0PxkjcCIs_jips/images/d15980a9-threaded_messages_list_item_config_cometchat_screens-c3d7bf21befe1c66eabca46bfba0e8c1.png?fit=max&auto=format&n=fW0PxkjcCIs_jips&q=85&s=ec30868ee90086710f0deab01c35af17" alt="Image" width="4498" height="3121" data-path="images/d15980a9-threaded_messages_list_item_config_cometchat_screens-c3d7bf21befe1c66eabca46bfba0e8c1.png" />
  </Tab>
</Tabs>

***

### MessageComposer

If you want to customize the properties of the [MessageComposer](/ui-kit/flutter/v4/message-composer) Widget inside ThreadedMessages Widget, you need use the `MessageComposerConfiguration` object.

**Example**

Here is the complete example for reference:

<Tabs>
  <Tab title="Dart">
    ```dart theme={null}
    CometChatThreadedMessages(
      loggedInUser: loggedInUser,
      parentMessage: parentMessage,
      messageComposerConfiguration: MessageComposerConfiguration(
        messageComposerStyle: MessageComposerStyle(
          background: Color(0xFFE4EBF5),
          border: Border.all(width: 1, color: Colors.red),
          borderRadius: 10,
        ),
      ),
    )
    ```
  </Tab>
</Tabs>

<Tabs>
  <Tab title="Android">
    <img src="https://mintcdn.com/cometchat-22654f5b-docs-agent-in-group-react-v6/hvldi1e9uY_02hWX/images/8850759f-threaded_messages_composer_config_cometchat_screens-4129477d24bc7dc06dba019e93fc06a4.png?fit=max&auto=format&n=hvldi1e9uY_02hWX&q=85&s=e88b3131611944e817e859efa9ea914e" alt="Image" width="4498" height="3121" data-path="images/8850759f-threaded_messages_composer_config_cometchat_screens-4129477d24bc7dc06dba019e93fc06a4.png" />
  </Tab>

  <Tab title="iOS">
    <img src="https://mintcdn.com/cometchat-22654f5b-docs-agent-in-group-react-v6/k82rLv-mRy38q-bk/images/e37e2d00-threaded_messages_composer_config_cometchat_screens-65508ebcd3a95fef2e6e5867b7de2cec.png?fit=max&auto=format&n=k82rLv-mRy38q-bk&q=85&s=aeeb337a0dc81e9d14bd082fbc41ec6c" alt="Image" width="4498" height="3121" data-path="images/e37e2d00-threaded_messages_composer_config_cometchat_screens-65508ebcd3a95fef2e6e5867b7de2cec.png" />
  </Tab>
</Tabs>
