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.
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 |
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.
CometChatUsers
CometChatUsers
as a Widget in the build MethodonSelection
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
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.
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.
onError
, allows users to override error handling within CometChatUsers
, providing greater control over error responses and actions.
onItemLongPress
, empowers users to customize long-click actions within CometChatUsers
, offering enhanced functionality and interaction possibilities.
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
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 |
CometChatUsers
widget. We provide exposed methods that allow you to modify the experience and behavior according to your specific needs.
CometChatUsersStyle
to the CometChatUsers
widget to customize the styling.
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. |
CometChatUsers
Widget.