Skip to main content

Overview

The CometChatUsers is a Widget, showcasing an accessible list of all available users. It provides an integral search functionality, allowing you to locate any specific user swiftly and easily. For each user listed, the widget displays the user’s name by default, in conjunction with their avatar when available. Furthermore, it includes a status indicator, visually informing you whether a user is currently online or offline.
Image
The CometChatUsers widget is composed of the following Base Widgets:

Usage

Integration

As CometChatUsers is a custom widget, it can be launched directly by user actions such as button clicks or other interactions. It’s also possible to integrate it into a tab widget. CometChatUsers offers several parameters and methods for UI customization. You can launch CometChatUsers 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 CometChatUsers
2. Embedding CometChatUsers 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. 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.

2. onItemTap
The onItemTap method is used to override the onClick behavior in CometChatUsers. 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.

3. onBack
This method allows users to override the onBack Pressed behavior in CometChatUsers 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.

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

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

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.
1. UsersRequestBuilder
The UsersRequestBuilder 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

Events

Events are emitted by a CometChatUsers 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. To handle events supported by Users you have to add corresponding listeners by using CometChatUserEvents

Customization

To fit your app’s design requirements, you can customize the appearance of the CometChatUsers 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 UsersStyle to the CometChatUsers widget to customize the styling.
Image
List of properties exposed by UsersStyle
2. Avatar Style
To apply customized styles to the Avatar widget in the CometChatUsers widget, you can use the following code snippet. For further insights on Avatar Styles refer

3. StatusIndicator Style
To apply customized styles to the Status Indicator widget in the CometChatUsers widget, You can use the following code snippet. For further insights on Status Indicator 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
List of properties exposed by CometChatUsers

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.

ListItemView

With this function, you can assign a custom ListItem to the CometChatUsers Widget.
Image
Example Here is the complete example for reference:
custom_list_item.dart
main.dart

SubtitleView

You can customize the subtitle view for each item to meet your specific preferences and needs.
Image

AppBarOptions

You can set the Custom AppBarOptions to the Conversations widget.
Image

EmptyStateView

You can set a custom EmptyStateView using setEmptyStateView to match the empty view of your app.
Image

ErrorStateView

You can set a custom ErrorStateView using setErrorStateView to match the error view of your app.
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