Skip to main content

Where It Fits

CometChatUsers is a contact list widget. It renders all available users and emits the selected User via onItemTap. Wire it to CometChatMessages or individual message components (CometChatMessageHeader, CometChatMessageList, CometChatMessageComposer) to build a standard two-panel chat layout.

Minimal Render

You can also launch it using Navigator.push:

Filtering Users

Pass a UsersRequestBuilder to usersRequestBuilder. Pass the builder instance — not the result of .build().

Filter Recipes

Default page size is 30. The component uses infinite scroll — the next page loads as the user scrolls to the bottom.

UsersRequestBuilder Properties

Refer to UsersRequestBuilder for the full builder API.

Actions and Events

Callback Props

onItemTap

Fires when a user row is tapped. Primary navigation hook — set the active user and render the message view.

onItemLongPress

Fires when a user row is long-pressed. Useful for showing context menus or custom actions.

onSelection

Fires when users are selected in multi-select mode. Requires selectionMode to be set.

onError

Fires on internal errors (network failure, auth issue, SDK exception).

onBack

Fires when the back button is pressed.

onLoad

Fires when the user list is successfully loaded.

onEmpty

Fires when the user list is empty.

Global UI Events

CometChatUserEvents emits events subscribable from anywhere in the application. Add a listener in initState and remove it in dispose. When to use: sync external UI with user state changes. For example, update a blocked users count badge when a user is blocked.

SDK Events (Real-Time, Automatic)

The component listens to these SDK events internally. No manual attachment needed unless additional side effects are required. Automatic: user presence changes (online/offline), blocked/unblocked state, connection recovery.

Custom View Slots

Each slot replaces a section of the default UI. Slots that accept a user parameter receive the User object for that row.

listItemView

Replace the entire list item row.

leadingView

Replace the avatar / left section.

titleView

Replace the name / title text. Role badge inline example.

subtitleView

Replace the subtitle text for each user.

trailingView

Replace the right section. Custom tag badge example.

setOptions

Replace the context menu / long-press actions on each user item.

addOptions

Add to the existing context menu actions without removing defaults.

appBarOptions

Add custom widgets to the app bar.
For a more complete popup menu with styling:

Styling

Set CometChatUsersStyle to customize the appearance.

Style Properties


Common Patterns

Custom empty state with CTA

Friends-only list

Multi-select with selection callback

Hide all chrome — minimal list

Online users only


Accessibility

The component renders a scrollable list of interactive items. Each user row supports:
  • Tap gesture for selection/navigation
  • Long-press gesture for context menu actions
  • Checkbox selection in multi-select mode with proper touch targets
  • Status indicators with visual feedback for online/offline state
For screen readers:
  • User names are readable as list item titles
  • Status indicators use color coding — consider adding Semantics widgets via leadingView if screen reader descriptions are needed for these visual indicators
  • Selection state is communicated through checkbox widgets
The component respects system accessibility settings including text scaling and high contrast modes.

Props

All props are optional unless noted.

activateSelection

Controls when selection mode activates. Values: ActivateSelection.onClick, ActivateSelection.onLongClick

addOptions

Adds additional context menu actions to the default options.

appBarOptions

Custom widgets to display in the app bar.

backButton

Custom back button widget.

controllerTag

Identifier tag for controller management.

emptyStateView

Custom view displayed when there are no users.

errorStateView

Custom view displayed when an error occurs.

height

Height of the widget.

hideAppbar

Hides the app bar including title and search.

hideSearch

Hides the search input box.

leadingView

Custom renderer for the avatar / left section.

listItemView

Custom renderer for the entire list item row.

loadingStateView

Custom view displayed during loading state.

onBack

Callback triggered when the back button is pressed.

onEmpty

Callback triggered when the user list is empty.

onError

Callback triggered when an error occurs.

onItemLongPress

Callback triggered on long press of a user item.

onItemTap

Callback triggered when tapping a user item.

onLoad

Callback triggered when the list is successfully loaded.

onSelection

Callback triggered when users are selected. Requires selectionMode to be set.

scrollController

Controller for scrolling the list.

searchBoxIcon

Custom search box icon widget.

searchKeyword

Pre-fills the search and filters the user list.

searchPlaceholder

Placeholder text for the search input box.

selectionMode

Enables single or multi-select mode. Values: SelectionMode.single, SelectionMode.multiple, SelectionMode.none

setOptions

Replaces the default context menu actions.

showBackButton

Shows or hides the back button.

stickyHeaderVisibility

Hides alphabetical section headers when set to true. Note: When false, alphabetical headers (A, B, C…) are shown to separate users.

submitIcon

Custom submit icon widget for selection mode.

subtitleView

Custom renderer for the subtitle text.

title

Title text displayed in the app bar.

titleView

Custom renderer for the name / title text.

trailingView

Custom renderer for the right section.

usersProtocol

Custom protocol for fetching users.

usersRequestBuilder

Controls which users load and in what order. Pass the builder instance, not the result of .build().

usersStatusVisibility

Shows or hides the online/offline status indicator on user avatars.

usersStyle

Styling options for the users list.

width

Width of the widget.

Events

CometChatUsers does not emit custom UI events. It subscribes to:

Customization Matrix


Conversations

Display recent one-on-one and group conversations

Groups

Display and manage group chats

Message List

Display messages in a conversation

Theming

Learn how to customize the look and feel