Skip to main content
{
  "component": "CometChatGroups",
  "package": "cometchat_chat_uikit",
  "import": "import 'package:cometchat_chat_uikit/cometchat_chat_uikit.dart';",
  "description": "Searchable, scrollable list of all available groups with icon, name, member count, and group type indicator.",
  "primaryOutput": {
    "prop": "onItemTap",
    "type": "Function(BuildContext context, Group group)?"
  },
  "props": {
    "data": {
      "groupsRequestBuilder": {
        "type": "GroupsRequestBuilder?",
        "default": "SDK default (30 per page)",
        "note": "Pass the builder, not the result of .build()"
      },
      "groupsProtocol": {
        "type": "GroupsBuilderProtocol?",
        "default": "null",
        "note": "Custom protocol for fetching groups"
      },
      "scrollController": {
        "type": "ScrollController?",
        "default": "null",
        "note": "Custom scroll controller for the list"
      },
      "title": {
        "type": "String?",
        "default": "Groups",
        "note": "Title text for the app bar"
      },
      "controllerTag": {
        "type": "String?",
        "default": "null",
        "note": "Tag for controller management"
      },
      "searchPlaceholder": {
        "type": "String?",
        "default": "null",
        "note": "Placeholder text for search input"
      },
      "searchKeyword": {
        "type": "String?",
        "default": "null",
        "note": "Pre-fills search and filters list"
      },
      "height": {
        "type": "double?",
        "default": "null"
      },
      "width": {
        "type": "double?",
        "default": "null"
      }
    },
    "callbacks": {
      "onItemTap": "Function(BuildContext context, Group group)?",
      "onItemLongPress": "Function(BuildContext context, Group group)?",
      "onSelection": "Function(List<Group>?)?",
      "onBack": "VoidCallback?",
      "onError": "OnError?",
      "onLoad": "OnLoad<Group>?",
      "onEmpty": "OnEmpty?",
      "stateCallBack": "Function(CometChatGroupsController controller)?"
    },
    "visibility": {
      "groupTypeVisibility": { "type": "bool?", "default": true },
      "hideAppbar": { "type": "bool?", "default": false },
      "hideError": { "type": "bool?", "default": false },
      "hideSearch": { "type": "bool", "default": false },
      "showBackButton": { "type": "bool", "default": true }
    },
    "selection": {
      "selectionMode": {
        "type": "SelectionMode?",
        "values": ["SelectionMode.single", "SelectionMode.multiple", "SelectionMode.none"],
        "default": "null"
      },
      "activateSelection": {
        "type": "ActivateSelection?",
        "values": ["ActivateSelection.onClick", "ActivateSelection.onLongClick"],
        "default": "null"
      }
    },
    "viewSlots": {
      "listItemView": "Widget Function(Group group)?",
      "leadingView": "Widget? Function(BuildContext context, Group group)?",
      "titleView": "Widget? Function(BuildContext context, Group group)?",
      "subtitleView": "Widget? Function(BuildContext context, Group group)?",
      "trailingView": "Widget? Function(BuildContext context, Group group)?",
      "loadingStateView": "WidgetBuilder?",
      "emptyStateView": "WidgetBuilder?",
      "errorStateView": "WidgetBuilder?",
      "setOptions": "List<CometChatOption>? Function(Group, CometChatGroupsController, BuildContext)?",
      "addOptions": "List<CometChatOption>? Function(Group, CometChatGroupsController, BuildContext)?",
      "appBarOptions": "List<Widget> Function(BuildContext context)?"
    },
    "icons": {
      "backButton": { "type": "Widget?", "default": "built-in back arrow" },
      "searchBoxIcon": { "type": "Widget?", "default": "built-in search icon" },
      "submitIcon": { "type": "Widget?", "default": "built-in check icon" },
      "passwordGroupIcon": { "type": "Widget?", "default": "built-in lock icon" },
      "privateGroupIcon": { "type": "Widget?", "default": "built-in shield icon" }
    },
    "style": {
      "groupsStyle": { "type": "CometChatGroupsStyle?", "default": "null" }
    }
  },
  "events": [
    { "name": "CometChatGroupEvents.ccGroupCreated", "payload": "Group", "description": "Group created" },
    { "name": "CometChatGroupEvents.ccGroupDeleted", "payload": "Group", "description": "Group deleted" },
    { "name": "CometChatGroupEvents.ccGroupLeft", "payload": "Action, User, Group", "description": "User left group" },
    { "name": "CometChatGroupEvents.ccGroupMemberJoined", "payload": "User, Group", "description": "User joined group" },
    { "name": "CometChatGroupEvents.ccGroupMemberAdded", "payload": "List<Action>, List<User>, Group, User", "description": "Members added" },
    { "name": "CometChatGroupEvents.ccGroupMemberKicked", "payload": "Action, User, User, Group", "description": "Member kicked" },
    { "name": "CometChatGroupEvents.ccGroupMemberBanned", "payload": "Action, User, User, Group", "description": "Member banned" },
    { "name": "CometChatGroupEvents.ccGroupMemberUnbanned", "payload": "Action, User, User, Group", "description": "Member unbanned" },
    { "name": "CometChatGroupEvents.ccGroupMemberScopeChanged", "payload": "Action, User, String, String, Group", "description": "Member scope changed" },
    { "name": "CometChatGroupEvents.ccOwnershipChanged", "payload": "Group, GroupMember", "description": "Ownership transferred" }
  ],
  "sdkListeners": [
    "onGroupMemberJoined",
    "onGroupMemberLeft",
    "onMemberAddedToGroup",
    "onGroupMemberKicked",
    "onGroupMemberBanned",
    "onGroupMemberScopeChanged",
    "onConnected"
  ],
  "compositionExample": {
    "description": "Group directory wired to message view",
    "components": [
      "CometChatGroups",
      "CometChatMessages",
      "CometChatMessageHeader",
      "CometChatMessageList",
      "CometChatMessageComposer"
    ],
    "flow": "onItemTap emits Group -> pass to CometChatMessages or individual message components"
  },
  "types": {
    "CometChatOption": {
      "id": "String?",
      "title": "String?",
      "icon": "String?",
      "iconWidget": "Widget?",
      "onClick": "VoidCallback?"
    },
    "SelectionMode": {
      "single": "SelectionMode.single",
      "multiple": "SelectionMode.multiple",
      "none": "SelectionMode.none"
    },
    "ActivateSelection": {
      "onClick": "ActivateSelection.onClick",
      "onLongClick": "ActivateSelection.onLongClick"
    }
  }
}

Where It Fits

CometChatGroups is a directory list widget. It renders available groups and emits the selected Group via onItemTap. Wire it to CometChatMessageHeader, CometChatMessageList, and CometChatMessageComposer to build a group chat layout.
import 'package:flutter/material.dart';
import 'package:cometchat_chat_uikit/cometchat_chat_uikit.dart';

class GroupChatApp extends StatefulWidget {
  const GroupChatApp({super.key});

  @override
  State<GroupChatApp> createState() => _GroupChatAppState();
}

class _GroupChatAppState extends State<GroupChatApp> {
  Group? selectedGroup;

  @override
  Widget build(BuildContext context) {
    return Scaffold(
      body: Row(
        children: [
          SizedBox(
            width: 400,
            child: CometChatGroups(
              onItemTap: (context, group) {
                setState(() {
                  selectedGroup = group;
                });
              },
            ),
          ),
          Expanded(
            child: selectedGroup != null
                ? CometChatMessages(group: selectedGroup)
                : const Center(child: Text('Select a group')),
          ),
        ],
      ),
    );
  }
}

Minimal Render

import 'package:flutter/material.dart';
import 'package:cometchat_chat_uikit/cometchat_chat_uikit.dart';

class GroupsDemo extends StatelessWidget {
  const GroupsDemo({super.key});

  @override
  Widget build(BuildContext context) {
    return const Scaffold(
      body: SafeArea(
        child: CometChatGroups(),
      ),
    );
  }
}
You can also launch it using Navigator.push:
Navigator.push(
  context, 
  MaterialPageRoute(builder: (context) => const CometChatGroups())
);

Filtering Groups

Pass a GroupsRequestBuilder to groupsRequestBuilder. Pass the builder instance — not the result of .build().
CometChatGroups(
  groupsRequestBuilder: GroupsRequestBuilder()
    ..joinedOnly = true
    ..limit = 10,
)

Filter Recipes

RecipeCode
Joined groups onlyGroupsRequestBuilder()..joinedOnly = true
Limit to 10 per pageGroupsRequestBuilder()..limit = 10
Search by keywordGroupsRequestBuilder()..searchKeyword = "design"
Filter by tagsGroupsRequestBuilder()..tags = ["vip"]
With tags dataGroupsRequestBuilder()..withTags = true
Default page size is 30. The component uses infinite scroll — the next page loads as the user scrolls to the bottom.

GroupsRequestBuilder Properties

PropertyDescriptionCode
limitNumber of groups to fetch per request...limit = 30
searchKeywordSearch groups by name...searchKeyword = "Team"
joinedOnlyFetch only joined groups. Default false...joinedOnly = true
tagsFilter groups by specific tags...tags = ["vip"]
withTagsInclude tags in the Group object. Default false...withTags = true
build()Builds and returns a GroupsRequest object..build()
Refer to GroupsRequestBuilder for the full builder API.

Actions and Events

Callback Props

onItemTap

Fires when a group row is tapped. Primary navigation hook — set the active group and render the message view.
CometChatGroups(
  onItemTap: (context, group) {
    print("Selected: ${group.name}");
  },
)

onItemLongPress

Fires when a group row is long-pressed. Useful for showing context menus or custom actions.
CometChatGroups(
  onItemLongPress: (context, group) {
    // Show custom context menu
  },
)

onSelection

Fires when groups are selected in multi-select mode. Requires selectionMode to be set.
CometChatGroups(
  selectionMode: SelectionMode.multiple,
  activateSelection: ActivateSelection.onClick,
  onSelection: (selectedList) {
    print("Selected ${selectedList?.length ?? 0} groups");
  },
)

onError

Fires on internal errors (network failure, auth issue, SDK exception).
CometChatGroups(
  onError: (error) {
    print("CometChatGroups error: $error");
  },
)

onBack

Fires when the back button is pressed.
CometChatGroups(
  showBackButton: true,
  onBack: () {
    Navigator.pop(context);
  },
)

onLoad

Fires when the group list is successfully loaded.
CometChatGroups(
  onLoad: (list) {
    print("Loaded ${list.length} groups");
  },
)

onEmpty

Fires when the group list is empty.
CometChatGroups(
  onEmpty: () {
    print("No groups found");
  },
)

Global UI Events

CometChatGroupEvents emits events subscribable from anywhere in the application. Add a listener in initState and remove it in dispose.
EventFires whenPayload
ccGroupCreatedA new group is createdGroup
ccGroupDeletedA group is deletedGroup
ccGroupLeftA user leaves a groupAction, User, Group
ccGroupMemberJoinedA user joins a groupUser, Group
ccGroupMemberAddedMembers are added to a groupList<Action>, List<User>, Group, User
ccGroupMemberKickedA member is kickedAction, User, User, Group
ccGroupMemberBannedA member is bannedAction, User, User, Group
ccGroupMemberUnbannedA member is unbannedAction, User, User, Group
ccGroupMemberScopeChangedA member’s scope changesAction, User, String, String, Group
ccOwnershipChangedGroup ownership is transferredGroup, GroupMember
When to use: sync external UI with group state changes. For example, update a group count badge when a group is created or deleted.
import 'package:cometchat_chat_uikit/cometchat_chat_uikit.dart';
import 'package:cometchat_sdk/models/action.dart' as cc;

class _YourScreenState extends State<YourScreen> with CometChatGroupEventListener {

  @override
  void initState() {
    super.initState();
    CometChatGroupEvents.addGroupsListener("listenerId", this);
  }

  @override
  void dispose() {
    CometChatGroupEvents.removeGroupsListener("listenerId");
    super.dispose();
  }

  @override
  void ccGroupCreated(Group group) {
    print("Group created: ${group.name}");
  }

  @override
  void ccGroupDeleted(Group group) {
    print("Group deleted: ${group.name}");
  }

  @override
  void ccGroupLeft(cc.Action message, User leftUser, Group leftGroup) {
    print("User ${leftUser.name} left ${leftGroup.name}");
  }

  @override
  void ccGroupMemberJoined(User joinedUser, Group joinedGroup) {
    print("User ${joinedUser.name} joined ${joinedGroup.name}");
  }

  @override
  void ccOwnershipChanged(Group group, GroupMember newOwner) {
    print("Ownership of ${group.name} transferred to ${newOwner.name}");
  }

  @override
  Widget build(BuildContext context) {
    return const Placeholder();
  }
}

SDK Events (Real-Time, Automatic)

The component listens to these SDK events internally. No manual attachment needed unless additional side effects are required.
SDK ListenerInternal behavior
onGroupMemberJoinedUpdates member count, sets hasJoined if current user joined
onGroupMemberLeftUpdates member count
onMemberAddedToGroupUpdates member count, adds group to list if current user was added
onGroupMemberKickedUpdates member count
onGroupMemberBannedUpdates member count
onGroupMemberScopeChangedUpdates member scope
Automatic: group membership changes, member count updates.

Custom View Slots

Each slot replaces a section of the default UI. Slots that accept a group parameter receive the Group object for that row.
SlotSignatureReplaces
listItemViewWidget Function(Group)Entire list item row
leadingViewWidget? Function(BuildContext, Group)Avatar / left section
titleViewWidget? Function(BuildContext, Group)Name / title text
subtitleViewWidget? Function(BuildContext, Group)Member count subtitle
trailingViewWidget? Function(BuildContext, Group)Right section
loadingStateViewWidgetBuilderLoading spinner
emptyStateViewWidgetBuilderEmpty state
errorStateViewWidgetBuilderError state
setOptionsList<CometChatOption>? Function(Group, Controller, BuildContext)Context menu actions (replaces default)
addOptionsList<CometChatOption>? Function(Group, Controller, BuildContext)Context menu actions (adds to default)
appBarOptionsList<Widget> Function(BuildContext)App bar action widgets

listItemView

Replace the entire list item row.
CometChatGroups(
  listItemView: (group) {
    return ListTile(
      title: Text(
        group.name,
        style: TextStyle(fontSize: 16, fontWeight: FontWeight.w500),
      ),
      subtitle: Text(
        "${group.membersCount} Members • ${group.description}",
        overflow: TextOverflow.ellipsis,
        style: TextStyle(fontSize: 14, color: Color(0xFF727272)),
      ),
      trailing: ElevatedButton(
        onPressed: () {
          CometChat.joinGroup(
            group.guid,
            group.type,
            onSuccess: (group) {
              // Handle success
            },
            onError: (error) {
              // Handle error
            },
          );
        },
        style: ElevatedButton.styleFrom(
          backgroundColor: Color(0xFFEDEAFA),
          elevation: 0,
          shape: RoundedRectangleBorder(borderRadius: BorderRadius.circular(1000)),
        ),
        child: Text("JOIN", style: TextStyle(color: Color(0xFF6852D6), fontSize: 12)),
      ),
    );
  },
)

leadingView

Replace the avatar / left section. Joined status badge example.
CometChatGroups(
  leadingView: (context, group) {
    return Stack(
      children: [
        CometChatAvatar(
          image: group.icon,
          name: group.name,
          style: CometChatAvatarStyle(borderRadius: BorderRadius.circular(8)),
        ),
        if (group.hasJoined)
          Positioned(
            bottom: -2,
            left: 0,
            right: 0,
            child: Container(
              padding: EdgeInsets.symmetric(horizontal: 4, vertical: 2),
              decoration: BoxDecoration(color: Color(0xFF09C26F)),
              child: Text(
                "Joined",
                textAlign: TextAlign.center,
                style: TextStyle(color: Colors.white, fontSize: 8, fontWeight: FontWeight.w600),
              ),
            ),
          ),
      ],
    );
  },
)

titleView

Replace the name / title text. Group type badge inline example.
CometChatGroups(
  titleView: (context, group) {
    return Row(
      children: [
        Text(
          group.name,
          style: TextStyle(fontWeight: FontWeight.w500, fontSize: 16),
        ),
        SizedBox(width: 4),
        Container(
          padding: EdgeInsets.symmetric(horizontal: 4, vertical: 2),
          decoration: BoxDecoration(
            color: group.type == GroupTypeConstants.public 
                ? Color(0xFF0B7BEA) 
                : Color(0xFF09C26F),
            borderRadius: BorderRadius.circular(7),
          ),
          child: Text(
            group.type,
            style: TextStyle(color: Colors.white, fontSize: 8, fontWeight: FontWeight.w600),
          ),
        ),
      ],
    );
  },
)

subtitleView

Replace the member count subtitle text.
CometChatGroups(
  subtitleView: (context, group) {
    return Text(
      "${group.membersCount} Members • ${group.description ?? 'No description'}",
      overflow: TextOverflow.ellipsis,
      style: TextStyle(fontSize: 14, color: Color(0xFF727272)),
    );
  },
)

trailingView

Replace the right section. Join status button example.
CometChatGroups(
  trailingView: (context, group) {
    return Container(
      padding: EdgeInsets.symmetric(horizontal: 12, vertical: 4),
      decoration: BoxDecoration(
        color: Color(0xFFEDEAFA),
        borderRadius: BorderRadius.circular(1000),
      ),
      child: Text(
        group.hasJoined ? "JOINED" : "+ JOIN",
        style: TextStyle(color: Color(0xFF6852D6), fontSize: 12, fontWeight: FontWeight.w700),
      ),
    );
  },
)

setOptions

Replace the context menu / long-press actions on each group item.
CometChatGroups(
  setOptions: (group, controller, context) {
    return [
      CometChatOption(
        id: "leave",
        title: "Leave Group",
        icon: AssetConstants.close,
        onClick: () {
          CometChat.leaveGroup(group.guid, onSuccess: (response) {
            print("Left group");
          }, onError: (error) {
            print("Error: $error");
          });
        },
      ),
      CometChatOption(
        id: "view_members",
        title: "View Members",
        iconWidget: Icon(Icons.people_outline),
        onClick: () {
          // Navigate to group members
        },
      ),
    ];
  },
)

addOptions

Add to the existing context menu actions without removing defaults.
CometChatGroups(
  addOptions: (group, controller, context) {
    return [
      CometChatOption(
        id: "mute",
        title: "Mute Notifications",
        iconWidget: Icon(Icons.notifications_off_outlined),
        onClick: () {
          // Mute notifications logic
        },
      ),
      CometChatOption(
        id: "pin",
        title: "Pin Group",
        iconWidget: Icon(Icons.push_pin_outlined),
        onClick: () {
          // Pin group logic
        },
      ),
    ];
  },
)

appBarOptions

Add custom widgets to the app bar.
CometChatGroups(
  appBarOptions: (context) => [
    IconButton(
      onPressed: () {
        // Navigate to create group
      },
      icon: Icon(Icons.group_add, color: Color(0xFF6852D6)),
    ),
  ],
)

Styling

Set CometChatGroupsStyle to customize the appearance.
CometChatGroups(
  groupsStyle: CometChatGroupsStyle(
    backgroundColor: Colors.white,
    titleTextColor: Color(0xFFF76808),
    separatorColor: Color(0xFFF76808),
    avatarStyle: CometChatAvatarStyle(
      borderRadius: BorderRadius.circular(8),
      backgroundColor: Color(0xFFFBAA75),
    ),
  ),
)

Style Properties

PropertyTypeDescription
backgroundColorColorBackground color of the component
borderBorderBorder for the widget
borderRadiusBorderRadiusGeometryBorder radius for the widget
titleTextColorColorColor of the header title
titleTextStyleTextStyleStyle for the header title
backIconColorColorBack button icon color
searchBackgroundColorColorBackground color of search box
searchBorderBorderSideBorder for search box
searchBorderRadiusBorderRadiusBorder radius for search box
searchPlaceHolderTextColorColorPlaceholder text color in search
searchPlaceHolderTextStyleTextStylePlaceholder text style in search
searchIconColorColorSearch icon color
searchInputTextColorColorSearch input text color
searchInputTextStyleTextStyleSearch input text style
separatorColorColorColor of list item separators
separatorHeightdoubleHeight of list item separators
itemTitleTextColorColorColor of group name in list items
itemTitleTextStyleTextStyleStyle for group name in list items
itemSubtitleTextColorColorColor of member count subtitle
itemSubtitleTextStyleTextStyleStyle for member count subtitle
listItemSelectedBackgroundColorColorBackground color for selected items
privateGroupIconBackgroundColorBackground color for private group icon
protectedGroupIconBackgroundColorBackground color for password group icon
emptyStateTextColorColorText color for empty state title
emptyStateTextStyleTextStyleText style for empty state title
emptyStateSubTitleTextColorColorText color for empty state subtitle
emptyStateSubTitleTextStyleTextStyleText style for empty state subtitle
errorStateTextColorColorText color for error state title
errorStateTextStyleTextStyleText style for error state title
errorStateSubTitleTextColorColorText color for error state subtitle
errorStateSubTitleTextStyleTextStyleText style for error state subtitle
retryButtonBackgroundColorColorBackground color for retry button
retryButtonBorderRadiusBorderRadiusBorder radius for retry button
retryButtonBorderBorderSideBorder for retry button
retryButtonTextColorColorText color for retry button
retryButtonTextStyleTextStyleText style for retry button
submitIconColorColorColor of submit icon in selection mode
checkBoxBackgroundColorColorBackground color of unchecked checkbox
checkBoxCheckedBackgroundColorColorBackground color of checked checkbox
checkboxSelectedIconColorColorColor of checkmark icon
checkBoxBorderRadiusBorderRadiusBorder radius for checkbox
checkBoxBorderBorderSideBorder for checkbox
avatarStyleCometChatAvatarStyleStyle for group avatars
statusIndicatorStyleCometChatStatusIndicatorStyleStyle for group type indicators

Common Patterns

Custom empty state with CTA

CometChatGroups(
  emptyStateView: (context) {
    return Center(
      child: Column(
        mainAxisAlignment: MainAxisAlignment.center,
        children: [
          Icon(Icons.group_outlined, size: 64, color: Color(0xFF727272)),
          SizedBox(height: 16),
          Text("No groups found", style: TextStyle(fontSize: 18, fontWeight: FontWeight.w500)),
          SizedBox(height: 8),
          ElevatedButton(
            onPressed: () {
              // Navigate to create group
            },
            child: Text("Create a Group"),
          ),
        ],
      ),
    );
  },
)

Joined groups only

CometChatGroups(
  groupsRequestBuilder: GroupsRequestBuilder()
    ..joinedOnly = true,
)

Multi-select with selection callback

CometChatGroups(
  selectionMode: SelectionMode.multiple,
  activateSelection: ActivateSelection.onClick,
  onSelection: (selectedGroups) {
    if (selectedGroups != null && selectedGroups.isNotEmpty) {
      print("Selected ${selectedGroups.length} groups");
      // Perform batch action on selected groups
    }
  },
)

Hide all chrome — minimal list

CometChatGroups(
  hideSearch: true,
  hideAppbar: true,
  groupTypeVisibility: false,
)

Accessibility

The component renders a scrollable list of interactive items. Each group row supports:
  • Tap gesture for selection/navigation
  • Long-press gesture for context menu actions
  • Checkbox selection in multi-select mode with proper touch targets
  • Group type indicators (public/private/password) with visual icons
For screen readers:
  • Group names are readable as list item titles
  • Group type indicators use icons — consider adding Semantics widgets via leadingView if screen reader descriptions are needed
  • 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.
TypeActivateSelection
Defaultnull
Values: ActivateSelection.onClick, ActivateSelection.onLongClick

addOptions

Adds additional context menu actions to the default options.
TypeList<CometChatOption>? Function(Group, CometChatGroupsController, BuildContext)
Defaultnull

appBarOptions

Custom widgets to display in the app bar.
TypeList<Widget> Function(BuildContext context)
Defaultnull

backButton

Custom back button widget.
TypeWidget
DefaultBuilt-in back arrow

controllerTag

Identifier tag for controller management.
TypeString
Defaultnull

emptyStateView

Custom view displayed when there are no groups.
TypeWidgetBuilder
DefaultBuilt-in empty state

errorStateView

Custom view displayed when an error occurs.
TypeWidgetBuilder
DefaultBuilt-in error state

groupsProtocol

Custom protocol for fetching groups.
TypeGroupsBuilderProtocol
Defaultnull

groupsRequestBuilder

Controls which groups load and in what order.
TypeGroupsRequestBuilder
DefaultSDK default (30 per page)
Pass the builder instance, not the result of .build().

groupsStyle

Styling options for the groups list.
TypeCometChatGroupsStyle
Defaultnull

groupTypeVisibility

Shows or hides the group type icon (public/private/password) on group avatars.
Typebool
Defaulttrue

height

Height of the widget.
Typedouble
Defaultnull

hideAppbar

Hides the app bar including title and search.
Typebool
Defaultfalse

hideError

Hides the error state view.
Typebool
Defaultfalse

hideSearch

Hides the search input box.
Typebool
Defaultfalse

leadingView

Custom renderer for the avatar / left section.
TypeWidget? Function(BuildContext context, Group group)
DefaultBuilt-in avatar

listItemView

Custom renderer for the entire list item row.
TypeWidget Function(Group group)
DefaultBuilt-in list item

loadingStateView

Custom view displayed during loading state.
TypeWidgetBuilder
DefaultBuilt-in shimmer

onBack

Callback triggered when the back button is pressed.
TypeVoidCallback
Defaultnull

onEmpty

Callback triggered when the group list is empty.
TypeOnEmpty
Defaultnull

onError

Callback triggered when an error occurs.
TypeOnError
Defaultnull

onItemLongPress

Callback triggered on long press of a group item.
TypeFunction(BuildContext context, Group group)
Defaultnull

onItemTap

Callback triggered when tapping a group item.
TypeFunction(BuildContext context, Group group)
Defaultnull

onLoad

Callback triggered when the list is successfully loaded.
TypeOnLoad<Group>
Defaultnull

onSelection

Callback triggered when groups are selected. Requires selectionMode to be set.
TypeFunction(List<Group>? list)
Defaultnull

passwordGroupIcon

Custom icon widget for password-protected groups.
TypeWidget
DefaultBuilt-in lock icon

privateGroupIcon

Custom icon widget for private groups.
TypeWidget
DefaultBuilt-in shield icon

scrollController

Controller for scrolling the list.
TypeScrollController
Defaultnull

searchBoxIcon

Custom search box icon widget.
TypeWidget
DefaultBuilt-in search icon

searchKeyword

Pre-fills the search and filters the group list.
TypeString
Defaultnull

searchPlaceholder

Placeholder text for the search input box.
TypeString
Defaultnull

selectionMode

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

setOptions

Replaces the default context menu actions.
TypeList<CometChatOption>? Function(Group, CometChatGroupsController, BuildContext)
Defaultnull

showBackButton

Shows or hides the back button.
Typebool
Defaulttrue

stateCallBack

Callback to access controller functions from parent.
TypeFunction(CometChatGroupsController controller)
Defaultnull

submitIcon

Custom submit icon widget for selection mode.
TypeWidget
DefaultBuilt-in check icon

subtitleView

Custom renderer for the member count subtitle.
TypeWidget? Function(BuildContext context, Group group)
DefaultBuilt-in member count

title

Title text displayed in the app bar.
TypeString
Default"Groups"

titleView

Custom renderer for the name / title text.
TypeWidget? Function(BuildContext context, Group group)
DefaultBuilt-in title

trailingView

Custom renderer for the right section.
TypeWidget? Function(BuildContext context, Group group)
Defaultnull

width

Width of the widget.
Typedouble
Defaultnull

Events

CometChatGroups subscribes to CometChatGroupEvents:
EventPayloadInternal behavior
ccGroupCreatedGroupAdds new group to list
ccGroupDeletedGroupRemoves group from list
ccGroupLeftAction, User, GroupRemoves private group or updates hasJoined
ccGroupMemberJoinedUser, GroupUpdates group in list
ccGroupMemberAddedList<Action>, List<User>, Group, UserUpdates group in list
ccGroupMemberKickedAction, User, User, GroupUpdates group in list
ccGroupMemberBannedAction, User, User, GroupUpdates group in list
ccOwnershipChangedGroup, GroupMemberUpdates group in list

Customization Matrix

What to changeWhereProperty/APIExample
Override behavior on group interactionComponent propson<Event> callbacksonItemTap: (ctx, group) => setActive(group)
Filter which groups appearComponent propsgroupsRequestBuildergroupsRequestBuilder: GroupsRequestBuilder()..joinedOnly = true
Toggle visibility of UI elementsComponent propshide<Feature> / show<Feature> boolean propshideSearch: true
Replace a section of the list itemComponent props<slot>View render propslistItemView: (group) => CustomWidget()
Change colors, fonts, spacingComponent propsgroupsStylegroupsStyle: CometChatGroupsStyle(titleTextColor: Colors.red)