Skip to main content

Contacts

CometChatContacts is a widget specifically designed to facilitate the display and management of users and groups within chat applications. It streamlines the process of showcasing all app users and available chat groups in a user-friendly interface, making it easier for users to connect and communicate effectively. Additionally, the widget includes a UI Segmented Control to switch between the users and groups list, enhancing navigation and usability.

Key Features:

  1. User List View: CometChatContacts presents a comprehensive list of all registered users within the application. This list allows users to quickly find and select specific individuals they wish to interact with.
  2. Group List View: This widget also offers a dedicated view to showcase all the available chat groups. This simplifies the process of joining or creating new group conversations.
  3. Smart Search Functionality: Users can utilize the powerful search feature to quickly locate specific users or groups by typing names or keywords. This ensures seamless navigation, even in applications with a large user base.
  4. Selection Mode: CometChatContacts supports a selection mode, enabling users to pick multiple contacts or groups simultaneously. This feature proves useful for creating group chats or forwarding messages to multiple recipients.
  5. Customizable Tab Layout: Developers can easily customize the appearance of the tabs, including text colors, indicator color, and background, to match the app's branding and aesthetics.
  6. Selection Limit Control: Developers have the flexibility to set a selection limit, restricting the number of contacts or groups a user can select during the selection mode. This helps maintain messaging policies and optimize user experience.
  7. User-Friendly Close Button: This widget provides a convenient close button feature, allowing users to exit the Contacts view and return to their previous screen or chat interface effortlessly.

How to integrate CometChatContacts

CometChatContacts can launched on to a new screen using the following code snippet.

1. Using Navigator to Launch CometChatContacts
Navigator.push(context, MaterialPageRoute(builder: (context) => const CometChatContacts()));
2. Embedding CometChatContacts as a Widget in the build Method
import 'package:cometchat_chat_uikit/cometchat_chat_uikit.dart';
import 'package:flutter/material.dart';

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


State<Conversations> createState() => _ConversationsState();
}

class _ConversationsState extends State<Conversations> {

Widget build(BuildContext context) {
return Scaffold(
body: SafeArea(
child: CometChatContacts(),
),
);
}
}

List of properties exposed by CometChatContacts

PropertyDescriptionCode
Activate SelectionUsed to specify if the listed conversations can be selected, selection can be activated on tap or on long pressactivateSelection: ActivateSelection
AppBar OptionsUsed to set the options available in the app barappBarOptions: List<Widget>
Back ButtonUsed to set back button located in the app barbackButton: Widget
ControllerUsed to programmatically update the scroll physics of list containing the conversationscontroller: ScrollController
Date PatternUsed to display a custom string instead of the timestamp show at the tail of the conversation itemdatePattern: String Function(Conversation conversation)
Disable MentionsDisables mentions formatter if truedisableMentions: bool
Disable ReceiptUsed to disable read receipts shown in the subtitle of the conversation item and also disabling the functionality of marking messages as read and delivereddisableReceipt: bool
Disable TypingIf true stops indicating if a participant in a conversation is typingdisableTyping: bool
Empty State TextUsed to set a custom text response when fetching the conversations has returned an empty listemptyStateText: String
Error State TextUsed to set a custom text response when some error occurs on fetching the list of conversationserrorStateText: String
Hide AppbarToggle visibility for app barhideAppbar: bool
Hide ErrorUsed to hide error on fetching conversationshideError: bool
Hide SearchUsed to toggle visibility for search boxhideSearch: bool
Hide SeparatorUsed to hide the divider separating the conversation itemshideSeparator: bool
Hide Section SeparatorUsed to hide the text separating grouped conversation itemshideSectionSeparator: bool
OptionsUsed to set options affecting the conversation item in some wayoptions: List<CometChatOption> Function(Conversation, BuildContext)
On BackUsed to set a call back triggered on tapping the back button in the app baronBack: VoidCallback
On ErrorUsed to set a callback triggered in case any error happens when fetching conversationsonError: OnError
On Item Long PressUsed to set a callback that would be triggered on long press on a conversation itemonItemLongPress: Function(Conversation)
On Item TapUsed to set a callback that would be triggered on tapping a conversation itemonItemTap: Function(Conversation)
On SelectionUsed to set a custom callback that would utilize the selected conversations to execute some taskonSelection: Function(List<Conversation>, BuildContext)
PopertiesTypesDescription
Private Group IconUsed to set icon shown in place of status indicator if the conversation is taking place in a private groupprivateGroupIcon: Widget
Protected Group IconUsed to set icon shown in place of status indicator if the conversation is taking place in a password protected groupprotectedGroupIcon: Widget
Receipt StyleUsed to customize the colors of receipt icons shown in the subtitle of the conversation item if disableReceipt is not truereceiptStyle: ReceiptStyle
Search Box IconUsed to set search Icon in the search fieldsearchBoxIcon: Widget
Search PlaceholderUsed to set placeholder text for the search fieldsearchPlaceholder: String
Selection IconChange selection iconselectionIcon: Widget
Sent IconUsed to customize the receipt icon shown in the subtitle of the conversation item if disableReceipt is not true and if the status of the last message in the conversation is sentsentIcon: Widget
Show Back ButtonUsed to toggle visibility for back buttonshowBackButton: bool
State CallBackUsed to set a callback that can be used to retrieve the business logic (an instance of CometChatConversationsController) of the widget, with which the parent widget of CometChatConversations can access the public methods available in the business logic widgetstateCallBack: Function(CometChatConversationsController)
Status Indicator StyleUsed to customise the status indicator shown if a user is onlinestatusIndicatorStyle: StatusIndicatorStyle
Subtitle ViewUsed to set a custom subtitle for every conversation itemsubtitleView: Widget Function(BuildContext, Conversation)
Tail ViewUsed to generate a custom trailing view for the conversation item, by default it shows the time sent of the last message and the unread messages counttailView: Widget Function(Conversation)
Text FormattersUsed to pass a list of text formatters to format the text shown in text subtitle of each conversation provided the last message is a text message and it contains mentionstextFormatters: List<CometChatTextFormatter>
ThemeUsed to set custom themetheme: CometChatTheme
TitleUsed to set the title in the app bartitle: String
Typing Indicator TextUsed to customize the text response shown in the subtitle of the conversation item if a participant of a conversation is typingtypingIndicatorText: String

ContactsStyle

CometChatContacts(
contactsStyle: ContactsStyle(
background: Colors.white300,
titleTextStyle: TextStyle(color: Colors.yellow),
borderColor: Colors.red,
iconTint: Colors.red,
activeTabColor: Colors.yellow
),
)

These property is used to customize the appearance of the CometChatContacts widget.

PropertyDescriptionCode
Active Icon TintTint color for active icons within the contacts widget.activeIconTint: Color?
Active Tab ColorColor of the active tab within the contacts widget.activeTabColor: Color?
Active Tab Title Text StyleText style for the title of the active tab.activeTabTitleTextStyle: TextStyle?
BackgroundBackground color or gradient of the contacts widget.background: Color? or Gradient?
BorderBorder of the contacts widget.border: Border?
Border ColorColor of the borders within the contacts widget.borderColor: Color?
Border RadiusBorder radius of the contacts widget.borderRadius: BorderRadius?
Close Icon TintTint color for the close icon within the contacts widget.closeIconTint: Color?
Create Icon TintTint color for the create icon within the contacts widget.createIconTint: Color?
GradientGradient background of the contacts widget.gradient: Gradient?
HeightHeight of the contacts widget.height: double?
Icon TintTint color for icons within the contacts widget.iconTint: Color?
Selected Tab ColorColor of the selected tab within the contacts widget.selectedTabColor: Color?
Selected Tab Text StyleText style for the selected tab within the contacts widget.selectedTabTextStyle: TextStyle?
Snackbar ConfigurationConfiguration settings for displaying snackbars.snackBarConfiguration: SnackBarConfiguration?
Tab BorderBorder side for tabs within the contacts widget.tabBorder: BorderSide?
Tab Border ColorColor of tabs within the contacts widget.tabBorderColor: Color?
Tab Border RadiusBorder radius for tabs within the contacts widget.tabBorderRadius: BorderRadius?
Tab ColorColor of tabs within the contacts widget.tabColor: Color?
Tab HeightHeight of tabs within the contacts widget.tabHeight: double?
Tab Text StyleText style for tabs within the contacts widget.tabTextStyle: TextStyle?
Tab VisibilityEnum specifying which tabs (users, groups) are visible.tabVisibility: TabVisibility
Tab WidthWidth of tabs within the contacts widget.tabWidth: double?
ThemeTheme object for customizing the appearance of the widget.theme: Theme?
Title Text StyleText style for titles within the contacts widget.titleTextStyle: TextStyle?
Users ConfigurationConfiguration settings for users list.usersConfiguration: UsersConfiguration?
WidthWidth of the contacts widget.width: double?