> ## Documentation Index
> Fetch the complete documentation index at: https://cometchat-013b37f0.mintlify.site/llms.txt
> Use this file to discover all available pages before exploring further.

# Users With Messages

## Overview

`CometChatUsersWithMessages` is a [Composite Widget](/ui-kit/flutter/v4/components-overview#composite-components) that seamlessly merges the functionalities of both the [Users](/ui-kit/flutter/v4/users) and [Messages](/ui-kit/flutter/v4/messages) modules. It empowers users to effortlessly navigate to any individual's chat window by simply clicking on their respective **list item** in the user list.

Additionally, `CometChatUsersWithMessages` inherits and encompasses all attributes available within the `CometChatUsersWithMessages` module, ensuring a comprehensive user experience.

<Tabs>
  <Tab title="Android">
    <img src="https://mintcdn.com/cometchat-013b37f0/-gjW8CRa44sH3jWe/images/58d5d200-users_with_messages_overview_cometchat_screens-07df299d590d103486a2d502251c8775.png?fit=max&auto=format&n=-gjW8CRa44sH3jWe&q=85&s=202ca050f60382d00a2fd26b6f1d7ace" alt="Image" width="4498" height="3121" data-path="images/58d5d200-users_with_messages_overview_cometchat_screens-07df299d590d103486a2d502251c8775.png" />
  </Tab>

  <Tab title="iOS">
    <img src="https://mintcdn.com/cometchat-013b37f0/Czw6a3oEz4RIW75k/images/e33b97a4-users_with_messages_overview_cometchat_screens-35c2140068a3394deb791f489f9a8845.png?fit=max&auto=format&n=Czw6a3oEz4RIW75k&q=85&s=a3d1bda9b2a50ab0dc65ab24aa61e240" alt="Image" width="4498" height="3121" data-path="images/e33b97a4-users_with_messages_overview_cometchat_screens-35c2140068a3394deb791f489f9a8845.png" />
  </Tab>
</Tabs>

| Widget                                  | Description                                                                                                           |
| --------------------------------------- | --------------------------------------------------------------------------------------------------------------------- |
| [Users](/ui-kit/flutter/v4/users)       | Standalone screen displaying a searchable user list. Inherits from `CometChatListBase` and wraps `CometChatUserList`. |
| [Messages](/ui-kit/flutter/v4/messages) | Chat interface for users and groups. Displays message list for logged-in user's interactions.                         |

## Usage

### Integration

Since `CometChatUsersWithMessages` is a widget, it can be launched either by a button click or through any event's trigger. It inherits all the customizable properties and methods of `CometChatUsers.`

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

<Tabs>
  <Tab title="Dart">
    ```dart theme={null}
    Navigator.push(context, MaterialPageRoute(builder: (context) => const CometChatUsersWithMessages()));
    ```
  </Tab>
</Tabs>

##### 2. Embedding `CometChatUsersWithMessages` 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 UsersWithMessages extends StatefulWidget {
      const UsersWithMessages({super.key});

      @override
      State<UsersWithMessages> createState() => _UsersWithMessagesState();
    }

    class _UsersWithMessagesState extends State<UsersWithMessages> {

      @override
      Widget build(BuildContext context) {
        return Scaffold(
            body: SafeArea(
                child: CometChatUsersWithMessages()
            )
        );
      }
    }
    ```
  </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.

***

##### 1. onItemTap

The `onItemTap` method is used to override the onClick behavior in `CometChatUsersWithMessages`. This action does not come with any predefined behavior. However, you have the flexibility to override this event and tailor it to suit your needs using the following code snippet.

<Tabs>
  <Tab title="Dart">
    ```dart theme={null}
    CometChatUsersWithMessages(
        usersConfiguration: UsersConfiguration(
          onItemTap: (context, user) {
            // TODO("Not yet implemented")
          },
        )
    )
    ```
  </Tab>
</Tabs>

***

##### 2. onItemLongPress

This method `onItemLongPress`, empowers users to customize long-click actions within `CometChatUsersWithMessages`, offering enhanced functionality and interaction possibilities.

<Tabs>
  <Tab title="Dart">
    ```dart theme={null}
    CometChatUsersWithMessages(
        usersConfiguration: UsersConfiguration(
          onItemLongPress: (context, user) {
            // TODO("Not yet implemented")
          },
        )
    )
    ```
  </Tab>
</Tabs>

***

##### 3. onBack

This method allows users to override the onBack Pressed behavior in `CometChatUsersWithMessages` by utilizing the `onBack` , providing customization options for handling the back action.

By default, this action has a predefined behavior: it simply dismisses the current widget. However, the flexibility of CometChat UI Kit allows you to override this standard behavior according to your application's specific requirements. You can define a custom action that will be performed instead when the back button is pressed.

<Tabs>
  <Tab title="Dart">
    ```dart theme={null}
    CometChatUsersWithMessages(
        usersConfiguration: UsersConfiguration(
          onBack: () {
            // TODO("Not yet implemented")
          },
        )
    )
    ```
  </Tab>
</Tabs>

***

##### 4. onError

This method `onError`, allows users to override error handling within `CometChatUsersWithMessages`, providing greater control over error responses and actions.

<Tabs>
  <Tab title="Dart">
    ```dart theme={null}
    CometChatUsersWithMessages(
        usersConfiguration: UsersConfiguration(
          onError: (e) {
            // TODO("Not yet implemented")
          },
        )
    )
    ```
  </Tab>
</Tabs>

***

##### 5. onSelection

When the `onSelection` event is triggered, it furnishes the list of selected users. This event can be invoked by any button or action within the interface. You have the flexibility to implement custom actions or behaviors based on the selected users.

This action does not come with any predefined behavior. However, you have the flexibility to override this event and tailor it to suit your needs using the following code snippet.

<Tabs>
  <Tab title="Dart">
    ```dart theme={null}
    CometChatUsersWithMessages(
        usersConfiguration: UsersConfiguration(
          onSelection: (userList, context) {
            // 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.

While the `CometChatUsersWithMessages` widget does not have filters, its widgets do, For more detail on individual filters of its widget refer to [Users Filters](/ui-kit/flutter/v4/users)[Messages Filters](/ui-kit/flutter/v4/messages)

By utilizing the [Configurations](#configurations) object of its widgets, you can apply filters.

In the following **example**, we're sorting `Users` by `UID's` and setting the `limit` to 10 using the `UsersRequestBuilder`.

##### 1. UsersRequestBuilder

The [UsersRequestBuilder](/sdk/flutter/retrieve-users) enables you to filter and customize the user list based on available parameters in UsersRequestBuilder. This feature allows you to create more specific and targeted queries when fetching users. The following are the parameters available in [UsersRequestBuilder](/sdk/flutter/retrieve-users)

<Tabs>
  <Tab title="Dart">
    ```dart theme={null}
    CometChatUsersWithMessages(
        usersConfiguration: UsersConfiguration(
            usersRequestBuilder: UsersRequestBuilder()
              ..limit = 5
              ..uids = ["user_uid"]
        )
    )
    ```
  </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 `CometChatUsersWithMessages` does not produce any events but its subwidget does.

***

## Customization

To fit your app's design requirements, you have the ability to customize the appearance of the `CometChatUsersWithMessages` 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. Users Style 🛑

You can set the `UsersWithMessagesStyle` to the `CometChatUsersWithMessages` Widget to customize the styling.

Example

<Tabs>
  <Tab title="Dart">
    ```dart theme={null}
    CometChatUsersWithMessages(
        usersConfiguration: UsersConfiguration(
            usersStyle: UsersStyle(
                background: Color(0xFFE4EBF5),
                backIconTint: Colors.black,
                separatorColor: Colors.black
            )
        )
    )
    ```
  </Tab>
</Tabs>

You can also customize its widget styles. For more details on individual widget styles, you can refer [Users Styles](/ui-kit/flutter/v4/users) and [Messages Styles](/ui-kit/flutter/v4/messages).

Styles can be applied to child widgets using their respective configurations.

***

### Functionality

Functionality is 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.

`CometChatUsersWithMessages` widget does not have any available functionality.

***

### 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 own widget and then incorporate those into the component.

UsersWithMessages component does not have any advanced-level customization . You can use Advanced customisation its [Components](/ui-kit/flutter/v4/components-overview#components). For more details on individual component functionalities, you can refer [Users Advanced](/ui-kit/flutter/v4/users#advance) and [Messages Advanced](/ui-kit/flutter/v4/messages#advanced).

<Tabs>
  <Tab title="Dart">
    ```dart theme={null}
    CometChatUsersWithMessages(
        usersConfiguration: UsersConfiguration()
    )
    ```
  </Tab>
</Tabs>

UsersWithMessages uses advanced-level customization of both Users & Messages components to achieve its default behavior.

1. UsersWithMessages utilizes the [Itemclicklistener](/ui-kit/flutter/v4/users#2-onitemtap) function of the `Users` subcomponent to navigate the [User](/ui-kit/flutter/v4/users) to [Messages](/ui-kit/flutter/v4/messages)

<Tabs>
  <Tab title="Android">
    <img src="https://mintcdn.com/cometchat-013b37f0/crySXmrfj1cbCy1Q/images/2acdb2ea-users_to_messages_cometchat_screens-d2f02fd147839dba68025b1874df19b6.png?fit=max&auto=format&n=crySXmrfj1cbCy1Q&q=85&s=f962fae05c26feea07209fde2426e3ee" alt="Image" width="4498" height="3121" data-path="images/2acdb2ea-users_to_messages_cometchat_screens-d2f02fd147839dba68025b1874df19b6.png" />
  </Tab>

  <Tab title="iOS">
    <img src="https://mintcdn.com/cometchat-013b37f0/BbVB2_oRtSz8V2hG/images/e811a908-users_to_messages_cometchat_screens-244e19a23a1938dddfb24bd4dddfd9e0.png?fit=max&auto=format&n=BbVB2_oRtSz8V2hG&q=85&s=5c81df179b6ab9623d4714b5a0d3557b" alt="Image" width="4498" height="3121" data-path="images/e811a908-users_to_messages_cometchat_screens-244e19a23a1938dddfb24bd4dddfd9e0.png" />
  </Tab>
</Tabs>

2. UsersWithMessages utilizes the [SetMenu](/ui-kit/flutter/v4/users) function of the `Messages` subcomponent to navigatefrom [Messages](/ui-kit/flutter/v4/messages) to Details.

<Tabs>
  <Tab title="Android">
    <img src="https://mintcdn.com/cometchat-013b37f0/qPj1u-01bVacwjS9/images/c202e963-users_with_messages_to_details_cometchat_screens-0f9bd15455c96a8d9897fa7147294daf.png?fit=max&auto=format&n=qPj1u-01bVacwjS9&q=85&s=eaf263b84ff25072d4a5321384663cc4" alt="Image" width="4498" height="3121" data-path="images/c202e963-users_with_messages_to_details_cometchat_screens-0f9bd15455c96a8d9897fa7147294daf.png" />
  </Tab>

  <Tab title="iOS">
    <img src="https://mintcdn.com/cometchat-013b37f0/cjVyusI_GGBVqQQt/images/1b3eb602-users_with_messages_to_details_cometchat_screens-387ac3d74bca834cbf7b99c7ecbd2c83.png?fit=max&auto=format&n=cjVyusI_GGBVqQQt&q=85&s=d9978d3d3d3f18f2476407bcce049217" alt="Image" width="4498" height="3121" data-path="images/1b3eb602-users_with_messages_to_details_cometchat_screens-387ac3d74bca834cbf7b99c7ecbd2c83.png" />
  </Tab>
</Tabs>

***

## Configurations

[Configurations](/ui-kit/flutter/v4/components-overview#configurations) offer the ability to customize the properties of each widget within a Composite widget.

**`CometChatUsersWithMessages`** has `Users` and `Messages` widget. Hence, each of these widgets will have its individual \`Configuration\`\`.

* `Configurations` expose properties that are available in its individual widgets.

#### Users

You can customize the properties of the Users widget by making use of the UsersConfiguration. You can accomplish this by employing the `.set(usersConfiguration: usersConfiguration)` method as demonstrated below:

<Tabs>
  <Tab title="Dart">
    ```dart theme={null}
    CometChatUsersWithMessages(
        usersConfiguration: UsersConfiguration()
    )
    ```
  </Tab>
</Tabs>

All exposed properties of `UsersConfiguration` can be found under [Users](/ui-kit/flutter/v4/users). Properties marked with the 🛑 symbol are not accessible within the Configuration Object.

**Example**

Let's say you want to change the style of the Users child widgets and, in addition, you only want to display users with offline status.

You can modify the style using the `UsersStyle` method and filter the list with the `UsersRequestBuilder` method.

<Tabs>
  <Tab title="Dart">
    ```dart theme={null}
    CometChatUsersWithMessages(
        usersConfiguration: UsersConfiguration(
            usersStyle: UsersStyle(
                background: Color(0xFFE4EBF5),
                backIconTint: Colors.black,
                separatorColor: Colors.black,
                searchBackground: Color(0xFFFAE6FA)
            )
        )
    )
    ```
  </Tab>
</Tabs>

<Tabs>
  <Tab title="Android">
    <img src="https://mintcdn.com/cometchat-013b37f0/Z7OD8lxLTfsN-Ym-/images/7016ef3d-users_with_messages_user_configuration_cometchat_screens-c926e94d61b7145359037f4f3705158a.png?fit=max&auto=format&n=Z7OD8lxLTfsN-Ym-&q=85&s=c6f44415b314add3de625afa1e84a06c" alt="Image" width="4498" height="3121" data-path="images/7016ef3d-users_with_messages_user_configuration_cometchat_screens-c926e94d61b7145359037f4f3705158a.png" />
  </Tab>

  <Tab title="iOS">
    <img src="https://mintcdn.com/cometchat-013b37f0/Dx3YUCFQDRLEoIQ3/images/da5dbc48-users_with_messages_user_configuration_cometchat_screens-071b40357c9375e02a863523e7ccdf11.png?fit=max&auto=format&n=Dx3YUCFQDRLEoIQ3&q=85&s=a8746451e9394f1c38aaaa7f5b6c43f7" alt="Image" width="4498" height="3121" data-path="images/da5dbc48-users_with_messages_user_configuration_cometchat_screens-071b40357c9375e02a863523e7ccdf11.png" />
  </Tab>
</Tabs>

***

#### Messages

You can customize the properties of the Messages widget by making use of the `messagesConfiguration`. You can accomplish this by employing the `messagesConfiguration` as demonstrated below:

<Tabs>
  <Tab title="Dart">
    ```dart theme={null}
    CometChatUsersWithMessages(
        messageConfiguration: MessageConfiguration()
    )
    ```
  </Tab>
</Tabs>

**Example**

<Tabs>
  <Tab title="Dart">
    ```dart theme={null}
    CometChatUsersWithMessages(
        messageConfiguration: MessageConfiguration(
            messagesStyle: MessagesStyle(
                background: Color(0xFFE4EBF5),
                borderRadius: 10,
            )
        )
    )
    ```
  </Tab>
</Tabs>

<Tabs>
  <Tab title="Android">
    <img src="https://mintcdn.com/cometchat-013b37f0/Z7OD8lxLTfsN-Ym-/images/70811bab-users_with_messages_message_configuration_cometchat_screens-8ab3d49d3ff654a4d444105150037ceb.png?fit=max&auto=format&n=Z7OD8lxLTfsN-Ym-&q=85&s=8c6c71a01e2d6456cac470116b2694d3" alt="Image" width="4498" height="3121" data-path="images/70811bab-users_with_messages_message_configuration_cometchat_screens-8ab3d49d3ff654a4d444105150037ceb.png" />
  </Tab>

  <Tab title="iOS">
    <img src="https://mintcdn.com/cometchat-013b37f0/IZ1rzMD0yphZc4Xc/images/e067e193-users_with_messages_message_configuration_cometchat_screens-b18d34f4f662d54ad085c9082b5d2810.png?fit=max&auto=format&n=IZ1rzMD0yphZc4Xc&q=85&s=731000726055ea070de432223f1ddb80" alt="Image" width="4498" height="3121" data-path="images/e067e193-users_with_messages_message_configuration_cometchat_screens-b18d34f4f662d54ad085c9082b5d2810.png" />
  </Tab>
</Tabs>

***
