CometChatGroups class

CometChatGroups is a component that displays a list of groups available in the app using Clean Architecture with BLoC pattern.

Fetched groups are listed down alphabetically and in order of recent activity. Groups are fetched using GroupsBloc which internally uses GroupsRepository.

This widget supports:

  • External BLoC injection via groupsBloc parameter (Requirement 9.2)
  • All existing constructor parameters for backward compatibility (Requirement 9.1)
  • BlocProvider to provide GroupsBloc to child widgets (Requirement 5.1)
CometChatGroups(
  groupsStyle: CometChatGroupsStyle(),
  onItemTap: (context, group) => navigateToGroup(group),
);
Inheritance

Constructors

CometChatGroups({Key? key, GroupsBloc? groupsBloc, GroupsBuilderProtocol? groupsProtocol, Widget? subtitleView(BuildContext context, Group group)?, Widget listItemView(Group group)?, CometChatGroupsStyle? groupsStyle, ScrollController? scrollController, String? searchPlaceholder, Widget? backButton, bool showBackButton = true, Widget? searchBoxIcon, bool hideSearch = false, SelectionMode? selectionMode, dynamic onSelection(List<Group>?)?, String? title, GroupsRequestBuilder? groupsRequestBuilder, bool? hideError, WidgetBuilder? loadingStateView, WidgetBuilder? emptyStateView, WidgetBuilder? errorStateView, List<Widget> appBarOptions(BuildContext context)?, Widget? passwordGroupIcon, Widget? privateGroupIcon, ActivateSelection? activateSelection, VoidCallback? onBack, dynamic onItemTap(BuildContext context, Group group)?, dynamic onItemLongPress(BuildContext context, Group group)?, OnError? onError, Widget? submitIcon, bool? hideAppbar = false, String? controllerTag, double? height, double? width, String? searchKeyword, OnLoad<Group>? onLoad, OnEmpty? onEmpty, bool? groupTypeVisibility = true, List<CometChatOption>? setOptions(Group group, GroupsBloc bloc, BuildContext context)?, List<CometChatOption>? addOptions(Group group, GroupsBloc bloc, BuildContext context)?, Widget? titleView(BuildContext context, Group group)?, Widget? leadingView(BuildContext context, Group group)?, Widget? trailingView(BuildContext context, Group group)?})
const

Properties

activateSelection ActivateSelection?
activateSelection lets the widget know if groups are allowed to be selected
final
addOptions List<CometChatOption>? Function(Group group, GroupsBloc bloc, BuildContext context)?
addOptions adds into the current List of actions available on the long press of list item
final
appBarOptions List<Widget> Function(BuildContext context)?
appBarOptions list of options to be visible in app bar
final
backButton Widget?
backButton back button
final
controllerTag String?
Group tag to create from, if this is passed its parent responsibility to close this @deprecated Use groupsBloc parameter for external bloc injection
final
emptyStateView WidgetBuilder?
emptyStateView returns view for empty state
final
errorStateView WidgetBuilder?
errorStateView returns view for error state behind the dialog
final
groupsBloc GroupsBloc?
groupsBloc Optional external GroupsBloc instance. If provided, this bloc will be used instead of creating a new one internally. This allows for custom bloc implementations with overridden hooks. Requirement: 9.2
final
groupsProtocol GroupsBuilderProtocol?
groupsProtocol set custom groups request builder protocol @deprecated Use groupsBloc for custom implementations
final
groupsRequestBuilder GroupsRequestBuilder?
groupsRequestBuilder custom request builder @deprecated Use groupsBloc for custom implementations
final
groupsStyle CometChatGroupsStyle?
groupsStyle sets style
final
groupTypeVisibility bool?
groupTypeVisibility Hide the group type icon which is visible on the group icon.
final
hashCode int
The hash code for this object.
no setterinherited
height double?
height provides height to the widget
final
hideAppbar bool?
hideAppbar toggle visibility for app bar
final
hideError bool?
hideError toggle visibility of error dialog
final
hideSearch bool
hideSearch switch on/ff search input
final
key Key?
Controls how one widget replaces another widget in the tree.
finalinherited
leadingView Widget? Function(BuildContext context, Group group)?
leadingView to set leading view for each group
final
listItemView Widget Function(Group group)?
listItemView set custom view for each group
final
loadingStateView WidgetBuilder?
loadingStateView returns view for loading state
final
onBack VoidCallback?
onBack callback triggered on closing this screen
final
onEmpty OnEmpty?
onEmpty callback triggered when the list is empty
final
onError OnError?
onError callback triggered on error
final
onItemLongPress → dynamic Function(BuildContext context, Group group)?
onItemLongPress callback triggered on pressing for long on a group item
final
onItemTap → dynamic Function(BuildContext context, Group group)?
onItemTap callback triggered on tapping a group item
final
onLoad OnLoad<Group>?
onLoad callback triggered when list is fetched and load
final
onSelection → dynamic Function(List<Group>?)?
onSelection function will be performed
final
passwordGroupIcon Widget?
passwordGroupIcon sets icon in status indicator for password group
final
privateGroupIcon Widget?
privateGroupIcon sets icon in status indicator for private group
final
runtimeType Type
A representation of the runtime type of the object.
no setterinherited
scrollController ScrollController?
scrollController sets controller for the list
final
searchBoxIcon Widget?
searchBoxIcon search icon
final
searchKeyword String?
searchKeyword Used to set searchKeyword to fetch initial list with
final
searchPlaceholder String?
searchPlaceholder placeholder text of search input
final
selectionMode SelectionMode?
selectionMode specifies mode groups module is opening in
final
setOptions List<CometChatOption>? Function(Group group, GroupsBloc bloc, BuildContext context)?
setOptions sets List of actions available on the long press of list item
final
showBackButton bool
showBackButton switch on/off back button
final
submitIcon Widget?
submitIcon will override the default submit icon
final
subtitleView Widget? Function(BuildContext context, Group group)?
subtitleView to set subtitle for each group
final
title String?
title sets title for the list
final
titleView Widget? Function(BuildContext context, Group group)?
titleView to set title view for each group
final
trailingView Widget? Function(BuildContext context, Group group)?
trailingView to set tailView for each group
final
width double?
width provides width to the widget
final

Methods

createElement() StatefulElement
Creates a StatefulElement to manage this widget's location in the tree.
inherited
createState() State<CometChatGroups>
Creates the mutable state for this widget at a given location in the tree.
override
debugDescribeChildren() List<DiagnosticsNode>
Returns a list of DiagnosticsNode objects describing this node's children.
inherited
debugFillProperties(DiagnosticPropertiesBuilder properties) → void
Add additional properties associated with the node.
inherited
noSuchMethod(Invocation invocation) → dynamic
Invoked when a nonexistent method or property is accessed.
inherited
toDiagnosticsNode({String? name, DiagnosticsTreeStyle? style}) DiagnosticsNode
Returns a debug representation of the object that is used by debugging tools and by DiagnosticsNode.toStringDeep.
inherited
toString({DiagnosticLevel minLevel = DiagnosticLevel.info}) String
A string representation of this object.
inherited
toStringDeep({String prefixLineOne = '', String? prefixOtherLines, DiagnosticLevel minLevel = DiagnosticLevel.debug, int wrapWidth = 65}) String
Returns a string representation of this node and its descendants.
inherited
toStringShallow({String joiner = ', ', DiagnosticLevel minLevel = DiagnosticLevel.debug}) String
Returns a one-line detailed description of the object.
inherited
toStringShort() String
A short, textual description of this widget.
inherited

Operators

operator ==(Object other) bool
The equality operator.
inherited