AI Agent Component Spec
AI Agent Component Spec
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.
- Dart

Minimal Render
- Dart
Navigator.push:
Filtering Users
Pass aUsersRequestBuilder to usersRequestBuilder. Pass the builder instance — not the result of .build().
- Dart
Filter Recipes
| Recipe | Code |
|---|---|
| Friends only | UsersRequestBuilder()..friendsOnly = true |
| Online users only | UsersRequestBuilder()..userStatus = CometChatUserStatus.online |
| Limit to 15 per page | UsersRequestBuilder()..limit = 15 |
| Search by keyword | UsersRequestBuilder()..searchKeyword = "alice" |
| Hide blocked users | UsersRequestBuilder()..hideBlockedUsers = true |
| Filter by roles | UsersRequestBuilder()..roles = ["admin", "moderator"] |
| Filter by tags | UsersRequestBuilder()..tags = ["vip"] |
| Specific UIDs | UsersRequestBuilder()..uids = ["uid1", "uid2"] |
UsersRequestBuilder Properties
| Property | Description | Code |
|---|---|---|
limit | Number of users to fetch per request. Maximum 100. | ..limit = 30 |
searchKeyword | Search users by name. | ..searchKeyword = "John" |
friendsOnly | Fetch only friends. Default false. | ..friendsOnly = true |
userStatus | Filter by status: CometChatUserStatus.online or CometChatUserStatus.offline. | ..userStatus = CometChatUserStatus.online |
hideBlockedUsers | Hide blocked users from the list. Default false. | ..hideBlockedUsers = true |
roles | Filter users by specific roles. | ..roles = ["admin"] |
tags | Filter users by specific tags. | ..tags = ["vip"] |
withTags | Include tags in the User object. Default false. | ..withTags = true |
uids | Fetch specific users by UIDs. | ..uids = ["uid1", "uid2"] |
build() | Builds and returns a UsersRequest object. | .build() |
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.- Dart
onItemLongPress
Fires when a user row is long-pressed. Useful for showing context menus or custom actions.- Dart
onSelection
Fires when users are selected in multi-select mode. RequiresselectionMode to be set.
- Dart
onError
Fires on internal errors (network failure, auth issue, SDK exception).- Dart
onBack
Fires when the back button is pressed.- Dart
onLoad
Fires when the user list is successfully loaded.- Dart
onEmpty
Fires when the user list is empty.- Dart
Global UI Events
CometChatUserEvents emits events subscribable from anywhere in the application. Add a listener in initState and remove it in dispose.
| Event | Fires when | Payload |
|---|---|---|
ccUserBlocked | A user is blocked | User |
ccUserUnblocked | A user is unblocked | User |
- Dart
SDK Events (Real-Time, Automatic)
The component listens to these SDK events internally. No manual attachment needed unless additional side effects are required.| SDK Listener | Internal behavior |
|---|---|
onUserOnline | Updates the user’s status indicator to online |
onUserOffline | Updates the user’s status indicator to offline |
ccUserBlocked | Updates blocked user in list |
ccUserUnblocked | Updates unblocked user in list |
onConnected | Refreshes user list when connection is re-established |
Custom View Slots
Each slot replaces a section of the default UI. Slots that accept a user parameter receive theUser object for that row.
| Slot | Signature | Replaces |
|---|---|---|
listItemView | Widget Function(User) | Entire list item row |
leadingView | Widget? Function(BuildContext, User) | Avatar / left section |
titleView | Widget? Function(BuildContext, User) | Name / title text |
subtitleView | Widget? Function(BuildContext, User) | Subtitle text |
trailingView | Widget? Function(BuildContext, User) | Right section |
loadingStateView | WidgetBuilder | Loading spinner |
emptyStateView | WidgetBuilder | Empty state |
errorStateView | WidgetBuilder | Error state |
setOptions | List<CometChatOption>? Function(User, CometChatUsersController, BuildContext) | Context menu actions (replaces default) |
addOptions | List<CometChatOption>? Function(User, CometChatUsersController, BuildContext) | Context menu actions (adds to default) |
appBarOptions | List<Widget> Function(BuildContext) | App bar action widgets |
listItemView
Replace the entire list item row.
- Dart
leadingView
Replace the avatar / left section.- Dart
titleView
Replace the name / title text. Role badge inline example.- Dart
subtitleView
Replace the subtitle text for each user.
- Dart
trailingView
Replace the right section. Custom tag badge example.- Dart
setOptions
Replace the context menu / long-press actions on each user item.- Dart
addOptions
Add to the existing context menu actions without removing defaults.- Dart
appBarOptions
Add custom widgets to the app bar.
- Dart
- Dart
Styling
SetCometChatUsersStyle to customize the appearance.
- Dart

Style Properties
| Property | Type | Description |
|---|---|---|
backgroundColor | Color? | Background color of the component |
border | Border? | Border for the widget |
borderRadius | BorderRadiusGeometry? | Border radius for the widget |
titleTextColor | Color? | Color of the header title |
titleTextStyle | TextStyle? | Style for the header title |
backIconColor | Color? | Back button icon color |
searchBackgroundColor | Color? | Background color of search box |
searchBorder | BorderSide? | Border for search box |
searchBorderRadius | BorderRadius? | Border radius for search box |
searchPlaceHolderTextColor | Color? | Placeholder text color in search |
searchPlaceHolderTextStyle | TextStyle? | Placeholder text style in search |
searchIconColor | Color? | Search icon color |
searchInputTextColor | Color? | Search input text color |
searchInputTextStyle | TextStyle? | Search input text style |
separatorColor | Color? | Color of list item separators |
separatorHeight | double? | Height of list item separators |
stickyTitleColor | Color? | Color of sticky alphabetical headers |
stickyTitleTextStyle | TextStyle? | Style for sticky alphabetical headers |
itemTitleTextColor | Color? | Color of user name in list items |
itemTitleTextStyle | TextStyle? | Style for user name in list items |
itemBorder | BoxBorder? | Border for list items |
listItemSelectedBackgroundColor | Color? | Background color for selected items |
emptyStateTextColor | Color? | Text color for empty state title |
emptyStateTextStyle | TextStyle? | Text style for empty state title |
emptyStateSubTitleTextColor | Color? | Text color for empty state subtitle |
emptyStateSubTitleTextStyle | TextStyle? | Text style for empty state subtitle |
errorStateTextColor | Color? | Text color for error state title |
errorStateTextStyle | TextStyle? | Text style for error state title |
errorStateSubTitleTextColor | Color? | Text color for error state subtitle |
errorStateSubTitleTextStyle | TextStyle? | Text style for error state subtitle |
retryButtonBackgroundColor | Color? | Background color for retry button |
retryButtonBorderRadius | BorderRadiusGeometry? | Border radius for retry button |
retryButtonBorder | BorderSide? | Border for retry button |
retryButtonTextColor | Color? | Text color for retry button |
retryButtonTextStyle | TextStyle? | Text style for retry button |
submitIconColor | Color? | Color of submit icon in selection mode |
checkBoxBackgroundColor | Color? | Background color of unchecked checkbox |
checkBoxCheckedBackgroundColor | Color? | Background color of checked checkbox |
checkboxSelectedIconColor | Color? | Color of checkmark icon |
checkBoxBorderRadius | BorderRadiusGeometry? | Border radius for checkbox |
checkBoxBorder | BorderSide? | Border for checkbox |
avatarStyle | CometChatAvatarStyle? | Style for user avatars |
statusIndicatorStyle | CometChatStatusIndicatorStyle? | Style for status indicators |
Common Patterns
Custom empty state with CTA
- Dart
Friends-only list
- Dart
Multi-select with selection callback
- Dart
Hide all chrome — minimal list
- Dart
Online users only
- Dart
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
- User names are readable as list item titles
- Status indicators use color coding — consider adding
Semanticswidgets vialeadingViewif screen reader descriptions are needed for these visual indicators - Selection state is communicated through checkbox widgets
Props
All props are optional unless noted.activateSelection
Controls when selection mode activates.| Type | ActivateSelection? |
| Default | null |
ActivateSelection.onClick, ActivateSelection.onLongClick
addOptions
Adds additional context menu actions to the default options.| Type | List<CometChatOption>? Function(User, CometChatUsersController, BuildContext)? |
| Default | null |
appBarOptions
Custom widgets to display in the app bar.| Type | List<Widget> Function(BuildContext context)? |
| Default | null |
backButton
Custom back button widget.| Type | Widget? |
| Default | Built-in back arrow |
controllerTag
Identifier tag for controller management.| Type | String? |
| Default | null |
emptyStateView
Custom view displayed when there are no users.| Type | WidgetBuilder? |
| Default | Built-in empty state |
errorStateView
Custom view displayed when an error occurs.| Type | WidgetBuilder? |
| Default | Built-in error state |
height
Height of the widget.| Type | double? |
| Default | null |
hideAppbar
Hides the app bar including title and search.| Type | bool? |
| Default | false |
hideSearch
Hides the search input box.| Type | bool |
| Default | false |
leadingView
Custom renderer for the avatar / left section.| Type | Widget? Function(BuildContext context, User user)? |
| Default | Built-in avatar |
listItemView
Custom renderer for the entire list item row.| Type | Widget Function(User user)? |
| Default | Built-in list item |
loadingStateView
Custom view displayed during loading state.| Type | WidgetBuilder? |
| Default | Built-in shimmer |
onBack
Callback triggered when the back button is pressed.| Type | VoidCallback? |
| Default | null |
onEmpty
Callback triggered when the user list is empty.| Type | OnEmpty? |
| Default | null |
onError
Callback triggered when an error occurs.| Type | OnError? |
| Default | null |
onItemLongPress
Callback triggered on long press of a user item.| Type | Function(BuildContext context, User user)? |
| Default | null |
onItemTap
Callback triggered when tapping a user item.| Type | Function(BuildContext context, User user)? |
| Default | null |
onLoad
Callback triggered when the list is successfully loaded.| Type | OnLoad<User>? |
| Default | null |
onSelection
Callback triggered when users are selected. RequiresselectionMode to be set.
| Type | Function(List<User>? list, BuildContext context)? |
| Default | null |
scrollController
Controller for scrolling the list.| Type | ScrollController? |
| Default | null |
searchBoxIcon
Custom search box icon widget.| Type | Widget? |
| Default | Built-in search icon |
searchKeyword
Pre-fills the search and filters the user list.| Type | String? |
| Default | null |
searchPlaceholder
Placeholder text for the search input box.| Type | String? |
| Default | null |
selectionMode
Enables single or multi-select mode.| Type | SelectionMode? |
| Default | null |
SelectionMode.single, SelectionMode.multiple, SelectionMode.none
setOptions
Replaces the default context menu actions.| Type | List<CometChatOption>? Function(User, CometChatUsersController, BuildContext)? |
| Default | null |
showBackButton
Shows or hides the back button.| Type | bool |
| Default | true |
stickyHeaderVisibility
Hides alphabetical section headers when set totrue.
| Type | bool? |
| Default | false |
false, alphabetical headers (A, B, C…) are shown to separate users.
submitIcon
Custom submit icon widget for selection mode.| Type | Widget? |
| Default | Built-in check icon |
subtitleView
Custom renderer for the subtitle text.| Type | Widget? Function(BuildContext context, User user)? |
| Default | null |
title
Title text displayed in the app bar.| Type | String? |
| Default | "Users" |
titleView
Custom renderer for the name / title text.| Type | Widget? Function(BuildContext context, User user)? |
| Default | Built-in title |
trailingView
Custom renderer for the right section.| Type | Widget? Function(BuildContext context, User user)? |
| Default | null |
usersProtocol
Custom protocol for fetching users.| Type | UsersBuilderProtocol? |
| Default | null |
usersRequestBuilder
Controls which users load and in what order.| Type | UsersRequestBuilder? |
| Default | SDK default (30 per page) |
.build().
usersStatusVisibility
Shows or hides the online/offline status indicator on user avatars.| Type | bool? |
| Default | true |
usersStyle
Styling options for the users list.| Type | CometChatUsersStyle |
| Default | CometChatUsersStyle() |
width
Width of the widget.| Type | double? |
| Default | null |
Events
CometChatUsers does not emit custom UI events. It subscribes to:
| Event | Payload | Internal behavior |
|---|---|---|
CometChatUserEvents.ccUserBlocked | User | Updates blocked user in list |
CometChatUserEvents.ccUserUnblocked | User | Updates unblocked user in list |
Customization Matrix
| What to change | Where | Property/API | Example |
|---|---|---|---|
| Override behavior on user interaction | Component props | on<Event> callbacks | onItemTap: (ctx, user) => setActive(user) |
| Filter which users appear | Component props | usersRequestBuilder | usersRequestBuilder: UsersRequestBuilder()..friendsOnly = true |
| Toggle visibility of UI elements | Component props | hide<Feature> / show<Feature> boolean props | hideSearch: true |
| Replace a section of the list item | Component props | <slot>View render props | listItemView: (user) => CustomWidget() |
| Change colors, fonts, spacing | Component props | usersStyle | usersStyle: CometChatUsersStyle(titleTextColor: Colors.red) |