CometChatGroups
functions as a standalone Widget designed to create a screen displaying a list of groups, with the added functionality of enabling users to search for specific groups. Acting as a container widget, CometChatGroups
encapsulates and formats the CometChatListBase
and CometChatGroupList
widgets without introducing any additional behavior of its own.
CometChatGroups
widget is composed of the following BaseWidget:
Widgets | Description |
---|---|
CometChatListBase | CometChatListBase serves as a container widget equipped with a title (navigationBar), search functionality (search-bar), background settings, and a container for embedding a list view. |
CometChatListItem | This widget renders information extracted from a Group object onto a tile, featuring a title, subtitle, leading view, and trailing view. |
CometChatGroups
is a custom widget, it can be launched directly by user actions such as button clicks or other interactions.
You can launch CometChatGroups
directly using Navigator.push
, or you can define it as a widget within the build
method of your State
class.
CometChatGroups
CometChatGroups
as a Widget in the build MethodonItemTap
action doesn’t have a predefined behavior. You can override this action using the following code snippet.
onBack
feature. This capability allows you to customize the behavior associated with navigating back within your app. Utilize the provided code snippet to override default behaviors and tailor the user experience according to your specific requirements.
onError
and improve error handling.
onItemLongPress
action doesn’t have a predefined behavior. You can override this action using the following code snippet.
onSelection
event is triggered, it furnishes the list of selected groups. 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 groups.
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.
Property | Description | Code |
---|---|---|
Joined Only | Flag to include only joined groups. Defaults to false . | joinedOnly: bool |
Limit | Number of results to limit the query. | limit: int |
Search Keyword | Keyword for searching groups. | searchKeyword: String |
Tags | Tags for filtering groups. | tags: List<String> |
With Tags | Flag to include tags in the results. Defaults to false . | withTags: bool |
CometChatGroups
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.
The list of events emitted by the CometChatGroups
widget is as follows.
Events | Description |
---|---|
ccGroupCreated | This gets triggered when the logged in user creates a group. |
ccGroupDeleted | This gets triggered when the logged in user deletes a group. |
ccGroupLeft | This gets triggered when the logged in user leaves a group. |
ccGroupMemberScopeChanged | This gets triggered when the logged in user changes the scope of another group member. |
ccGroupMemberBanned | This gets triggered when the logged in user bans a group member from the group. |
ccGroupMemberKicked | This gets triggered when the logged in user kicks another group member from the group. |
ccGroupMemberUnbanned | This gets triggered when the logged in user unbans a user banned from the group. |
ccGroupMemberJoined | This gets triggered when the logged in user joins a group. |
ccGroupMemberAdded | This gets triggered when the logged in user adds new members to the group. |
ccOwnershipChanged | This gets triggered when the logged in user transfers the ownership of their group to some other member. |
CometChatGroups
Widget by setting the CometChatGroupsStyle
to customize its appearance.
CometChatGroups
Property | Data Type | Description |
---|---|---|
groupsProtocol | GroupsBuilderProtocol? | Custom groups request builder protocol. |
groupsRequestBuilder | GroupsRequestBuilder? | Custom request builder for fetching groups. |
subtitleView | Widget? Function(BuildContext, Group)? | Widget to set subtitle for each group item. |
listItemView | Widget Function(Group)? | Custom view for each group item. |
groupsStyle | CometChatGroupsStyle? | Styling options for the groups 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 groups can be selected. |
onSelection | Function(List<Group>?)? | Callback for handling group selection. |
title | String? | Title of the widget. |
stateCallBack | Function(CometChatGroupsController)? | Callback to access controller functions. |
hideError | bool? | Toggle visibility of error dialog. |
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)? | Options available in the app bar. |
passwordGroupIcon | Widget? | Widget for password-protected group icon. |
privateGroupIcon | Widget? | Widget for private group icon. |
activateSelection | ActivateSelection? | Controls whether selection is allowed. |
onBack | VoidCallback? | Callback triggered when going back. |
onItemTap | Function(BuildContext, Group)? | Callback triggered when tapping a group. |
onItemLongPress | Function(BuildContext, Group)? | Callback triggered on long press of a group. |
onError | OnError? | Callback for handling errors. |
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. |
searchKeyword | String? | Keyword used to fetch initial group list. |
onLoad | OnLoad<Group>? | Callback triggered when the list loads. |
onEmpty | OnEmpty? | Callback triggered when the list is empty. |
groupTypeVisibility | bool | Hide the group type icon visible on the group icon. |
setOptions | List<CometChatOption>? Function(Group, CometChatGroupsController, BuildContext)? | Actions available on long-press of a group. |
addOptions | List<CometChatOption>? Function(Group, CometChatGroupsController, BuildContext)? | Additional long-press actions for groups. |
titleView | Widget? Function(BuildContext, Group)? | Custom title view for each group. |
leadingView | Widget? Function(BuildContext, Group)? | Widget for the leading section of each group. |
trailingView | Widget? Function(BuildContext, Group)? | Widget for the trailing section of each group. |
CometChatGroups
Widget.
appBarOptions
to the CometChatGroups
widget.