Overview
TheCometChatUsers
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.

CometChatUsers
widget is composed of the following Base Widgets:
Widgets | Description |
---|---|
ListBase | a reusable container widget having title, search box, customisable background and a List View |
ListItem | a widget that renders data obtained from a User object on a Tile having a title, subtitle, leading and trailing view |
Usage
Integration
AsCometChatUsers
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.onSelection
When theonSelection
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.
onItemTap
TheonItemTap
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.
onBack
This method allows users to override the onBack Pressed behavior inCometChatUsers
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.
onError
This methodonError
, allows users to override error handling within CometChatUsers
, providing greater control over error responses and actions.
onItemLongPress
This methodonItemLongPress
, empowers users to customize long-click actions within CometChatUsers
, offering enhanced functionality and interaction possibilities.
onLoad
Invoked when the list is successfully fetched and loaded, helping track component readiness.onEmpty
Called when the list is empty, enabling custom handling such as showing a placeholder message.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 UsersRequestBuilderEvents
Events are emitted by aCometChatUsers
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
Events | Description |
---|---|
ccUserBlocked | This will get triggered when the logged in user blocks another user |
ccUserUnblocked | This will get triggered when the logged in user unblocks another user |
Customization
To fit your app’s design requirements, you can customize the appearance of theCometChatUsers
widget. We provide exposed methods that allow you to modify the experience and behavior according to your specific needs.
Style
You can set theCometChatUsersStyle
to the CometChatUsers
widget to customize the styling.

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.
List of properties exposed by CometChatUsers
Property | Data Type | Description |
---|---|---|
usersProtocol | UsersBuilderProtocol? | Custom users request builder protocol. |
usersRequestBuilder | UsersRequestBuilder? | Custom request builder for fetching users. |
subtitleView | Widget? Function(BuildContext, User) | Widget to set subtitle for each user item. |
listItemView | Widget Function(User) | Custom view for each user item. |
usersStyle | CometChatUsersStyle | Styling options for the users list. |
scrollController | ScrollController? | Controller for scrolling the list. |
searchPlaceholder | String? | Placeholder text for the search input box. |
backButton | Widget? | Widget for the back button in the app bar. |
showBackButton | bool | Flag to show/hide the back button. |
searchBoxIcon | Widget? | Widget for the search box icon. |
hideSearch | bool | Flag to show/hide the search input box. |
selectionMode | SelectionMode? | Mode defining how users can be selected. |
onSelection | Function(List<User>?, BuildContext)? | Callback for handling user selection. |
loadingStateView | WidgetBuilder? | View displayed during loading state. |
emptyStateView | WidgetBuilder? | View displayed when the list is empty. |
errorStateView | WidgetBuilder? | View displayed when an error occurs. |
appBarOptions | List<Widget> Function(BuildContext context)? | Options available in the app bar. |
usersStatusVisibility | bool? | Hide status indicator on user avatars. |
activateSelection | ActivateSelection? | Controls whether selection is allowed. |
onError | OnError? | Callback for handling errors. |
onBack | VoidCallback? | Callback triggered when going back. |
onItemTap | Function(BuildContext context, User)? | Callback triggered when tapping a user. |
onItemLongPress | Function(BuildContext context, User)? | Callback triggered on long press of a user. |
submitIcon | Widget? | Widget for displaying the submit icon. |
hideAppbar | bool? | Flag to show/hide the app bar. |
controllerTag | String? | Identifier tag for controller management. |
height | double? | Height of the widget. |
width | double? | Width of the widget. |
stickyHeaderVisibility | bool? | Hide alphabets used to separate users. |
searchKeyword | String? | Keyword used to fetch initial user list. |
onLoad | OnLoad<User>? | Callback triggered when the list loads. |
onEmpty | OnEmpty? | Callback triggered when the list is empty. |
addOptions | List<CometChatOption>? Function(User, CometChatUsersController, BuildContext)? | Additional long-press actions for users. |
setOptions | List<CometChatOption>? Function(User, CometChatUsersController, BuildContext)? | Actions available on long-press of a user. |
titleView | Widget? Function(BuildContext, User)? | Custom title view for each user. |
leadingView | Widget? Function(User)? | Widget for leading section of each user. |
trailingView | Widget? Function(User)? | Widget for trailing section of each user. |
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.setOptions
This method sets a predefined list of actions that users can perform when they long press a user in the list. These options typically include:- Muting notifications for a specific user.
addOptions
This method extends the existing set of actions available when users long press a user item. Unlike setOptionsDefines, which replaces the default options, addOptionsAdds allows developers to append additional actions without removing the default ones. Example use cases include:- Adding a “Report Spam” action.
- Introducing a “Save to Notes” option.
- Integrating third-party actions such as “Share to Cloud Storage”.
loadingStateView
This method allows developers to set a custom loading view that is displayed when data is being fetched or loaded within the component. Instead of using a default loading spinner, a custom animation, progress bar, or branded loading screen can be displayed.- Showing a skeleton loader for users while data loads.
- Displaying a custom progress indicator with branding.
- Providing an animated loading experience for a more engaging UI.
emptyStateView
Configures a custom view to be displayed when there are no users. This improves the user experience by providing meaningful content instead of an empty screen.- Displaying a message like “No users yet. Start a new chat!”.
- Showing an illustration or animation to make the UI visually appealing.
- Providing a button to start a new user.
errorStateView
Defines a custom error state view that appears when an issue occurs while loading users or messages. This enhances the user experience by displaying friendly error messages instead of generic system errors.- Showing “Something went wrong. Please try again.” with a retry button.
- Displaying a connection issue message if the user is offline.
- Providing troubleshooting steps for the error.
leadingView
This method allows developers to set a custom leading view element that appears at the beginning of each user item. Typically, this space is used for profile pictures, avatars, or user badges.- Profile Pictures & Avatars – Display user profile images with online/offline indicators.
- Custom Icons or Badges – Show role-based badges (Admin, VIP, Verified) before the user name.
- Status Indicators – Add an active status ring or colored border based on availability.
titleView
This method customizes the title view of each user item, which typically displays the user’s name. It allows for styling modifications, additional metadata, or inline action buttons.- Styled Usernames – Customize fonts, colors, or text sizes for the name display.
- Additional Metadata – Show extra details like username handles or job roles.
- Inline Actions – Add a follow button or verification checkmark next to the name.
trailingView
This method allows developers to customize the trailing (right-end) section of each user item, typically used for actions like buttons, icons, or extra information.- Quick Actions – Add a follow/unfollow button.
- Notification Indicators – Show unread message counts or alert icons.
- Custom Info Display – Display last active time or mutual connections.
ListItemView
With this function, you can assign a custom ListItem to theCometChatUsers
Widget.

custom_list_item.dart
main.dart
SubtitleView
You can customize the subtitle view for each item to meet your specific preferences and needs.
AppBarOptions
You can set the Custom AppBarOptions to the Conversations widget.