CometChat class

Flutter wrapper for using CometChat SDK.

for more information on how to use wrapper effectively.

Constructors

CometChat(String appId, {@deprecated String? authKey, String region = 'us'})
Constructor for creating CometChat object appId refers to your CometChat App ID. region The region where the app was created.

Properties

appId String
final
authKey String?
Use this only for testing purpose
final
hashCode int
The hash code for this object.
no setterinherited
region String
final
runtimeType Type
A representation of the runtime type of the object.
no setterinherited

Methods

noSuchMethod(Invocation invocation) → dynamic
Invoked when a nonexistent method or property is accessed.
inherited
toString() String
A string representation of this object.
inherited

Operators

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

Static Properties

nativeStream Stream?
This is stream channel to receiver messages
getter/setter pair

Static Methods

acceptCall(String sessionID, {required dynamic onSuccess(Call call)?, required dynamic onError(CometChatException excep)}) → void
addCallListener(String listenerId, CallListener listenerClass) → dynamic
addConnectionListener(String listenerId, ConnectionListener listenerClass) → dynamic
The ConnectionListener class provides you with all the status of the connection to CometChat web-socket servers
addGroupListener(String listenerId, GroupListener listenerClass) → dynamic
The GroupListener class provides you with all the real-time events related to groups
addloginListener(String listenerId, LoginListener listenerClass) → dynamic
The LoginListener class provides you with all the real-time updates for the login and logout events
addMembersToGroup({required String guid, required List<GroupMember> groupMembers, required dynamic onSuccess(Map<String?, String?> result)?, required dynamic onError(CometChatException excep)?}) Future<Map<String?, String?>?>
Add members to the group
addMessageListener(String listenerId, MessageListener listenerClass) → dynamic
For every activity or fragment you wish to receive messages in, you need to register the MessageListener
addUserListener(String listenerId, UserListener listenerClass) → dynamic
The UserListener class provides you with live events related to users listenerId unique id for listener
banGroupMember({required String guid, required String uid, required dynamic onSuccess(String result)?, required dynamic onError(CometChatException excep)?}) Future<String?>
Admin or Moderator of a group can ban a member of the group
blockUser(List<String>? uids, {required dynamic onSuccess(Map<String, dynamic> map)?, required dynamic onError(CometChatException excep)?}) Future<Map<String, dynamic>?>
Block a user from sending logged-in user any messages.
callExtension(String slug, String requestType, String endPoint, Map<String, dynamic>? body, {required dynamic onSuccess(Map<String, dynamic> map)?, required dynamic onError(CometChatException excep)?}) Future<Map<String, dynamic>?>
can call any extension
connect() Future<Null>
will establish the Web-socket connections manually
createGroup({required Group group, required dynamic onSuccess(Group group)?, required dynamic onError(CometChatException excep)?}) Future<Group?>
Returns a Group object after creating in CometChat API.
createUser(User user, String authKey, {required dynamic onSuccess(User user)?, required dynamic onError(CometChatException excep)?}) Future<User?>
Method returns user after creation in cometchat environment
deleteConversation(String conversationWith, String conversationType, {required dynamic onSuccess(String message)?, required dynamic onError(CometChatException excep)?}) → dynamic
Method deletes the conversation only for the logged-in user.
deleteGroup(String guid, {required dynamic onSuccess(String message)?, required dynamic onError(CometChatException excep)?}) Future<void>
In order to delete a group.
deleteMessage(int messageId, {required dynamic onSuccess(BaseMessage message)?, required dynamic onError(CometChatException excep)?}) Future<void>
Deletes the message with specified messageId.
disconnect() Future<Null>
will disable the Web-socket connections manually
editMessage(BaseMessage message, {required dynamic onSuccess(BaseMessage retMessage)?, required dynamic onError(CometChatException excep)?}) → dynamic
edit a message, you can use the editMessage() method
endCall(String sessionID, {required dynamic onSuccess(Call call)?, required dynamic onError(CometChatException excep)}) → void
endTyping({String? receaverUid, String? receiverType}) → dynamic
method to inform the receiver that the logged in user has ended typing.
getActiveCall() Future<Call?>
getConnectionStatus() Future<String>
getConversation(String conversationWith, String conversationType, {required dynamic onSuccess(Conversation conversation)?, required dynamic onError(CometChatException excep)?}) Future<Conversation?>
In order to fetch a specific conversation
getConversationFromMessage(BaseMessage message, {required dynamic onSuccess(Conversation conversation)?, required dynamic onError(CometChatException excep)?}) Future<Conversation?>
get the conversation object from message object.
getGroup(String guid, {required dynamic onSuccess(Group retGrou)?, required dynamic onError(CometChatException excep)?}) Future<Group?>
Retrieve information for a specific group
getLastDeliveredMessageId({dynamic onSuccess(int lastMessageId)?}) Future<int?>
getLoggedInUser({dynamic onSuccess(User)?, dynamic onError(CometChatException excep)?}) Future<User?>
Returns logged in User Object
getMessageReceipts(int messageId, {required dynamic onSuccess(List<MessageReceipt> messageReceipt)?, required dynamic onError(CometChatException excep)?}) Future<List<MessageReceipt>?>
Method to get message receipts.
getOnlineGroupMemberCount(List<String> guids, {required dynamic onSuccess(Map<String, int> result)?, required dynamic onError(CometChatException excep)?}) Future<Map<String, int>?>
get the total count of online users in particular groups
getOnlineUserCount({required dynamic onSuccess(int count)?, required dynamic onError(CometChatException excep)?}) Future<int?>
get the total count of online users for your app
getUnreadMessageCount({bool? hideMessagesFromBlockedUsers, dynamic onSuccess(Map<String, Map<String, int>> message)?, dynamic onError(CometChatException excep)?}) Future<Map<String, Map<String, int>>?>
Gives count of unread messages for every one-on-one and group conversation.
getUnreadMessageCountForAllGroups({bool? hideMessagesFromBlockedUsers, dynamic onSuccess(Map<String, int> message)?, dynamic onError(CometChatException excep)?}) Future<Map<String, int>?>
Gives count of unread messages for every one-on-one and group conversation.
getUnreadMessageCountForAllUsers({bool? hideMessagesFromBlockedUsers, dynamic onSuccess(Map<String, int> message)?, dynamic onError(CometChatException excep)?}) Future<Map<String, int>?>
Gives count of unread messages for every one-on-one and group conversation.
getUnreadMessageCountForGroup({required String guid, bool? hideMessagesFromBlockedUsers, dynamic onSuccess(Map<String, int> message)?, dynamic onError(CometChatException excep)?}) Future<Map<String, int>?>
Gives count of unread messages for every one-on-one and group conversation.
getUser(String uid, {required dynamic onSuccess(User user)?, required dynamic onError(CometChatException excep)?}) Future<User?>
Retrieve Particular User Details
getUserAuthToken() Future<String?>
init(String appId, AppSettings appSettings, {required dynamic onSuccess(String successMessage)?, required dynamic onError(CometChatException e)?}) Future<void>
method initializes the settings required for CometChat
initializetestmessageStream() → dynamic
initiateCall(Call call, {required dynamic onSuccess(Call call)?, required dynamic onError(CometChatException excep)}) → void
isExtensionEnabled(String extensionId, {dynamic onSuccess(bool)?, dynamic onError(CometChatException excep)?}) Future<bool>
joinGroup(String guid, String groupType, {String password = '', required dynamic onSuccess(Group group)?, required dynamic onError(CometChatException excep)?}) Future<Group?>
Returns a Group object after joining the logged in user to specified group. In order to start participating in group conversations, you will have to join a group
kickGroupMember({required String guid, required String uid, required dynamic onSuccess(String result)?, required dynamic onError(CometChatException excep)?}) Future<String?>
Admin or Moderator of a group can kick a member out of the group
leaveGroup(String guid, {required dynamic onSuccess(String returnResponse)?, required dynamic onError(CometChatException excep)?}) Future<void>
In order to stop receiving updates and messages for any particular joined group.
loadPubspecYaml() Future<String>
login(String uid, String authKey, {required dynamic onSuccess(User user)?, required dynamic onError(CometChatException excep)?}) Future<User?>
Use this function only for testing purpose. For production, use loginWithAuthToken
loginWithAuthToken(String authToken, {required dynamic onSuccess(User user)?, required dynamic onError(CometChatException excep)?}) Future<User?>
Returns a User object after login in CometChat API.
logout({required dynamic onSuccess(String message)?, required dynamic onError(CometChatException excep)?}) Future<void>
Method to log out the user from CometChat
markAsDelivered(BaseMessage message, {required dynamic onSuccess(String message)?, required dynamic onError(CometChatException excep)?}) → dynamic
Mark the messages for a particular conversation as delivered .
markAsRead(BaseMessage baseMessage, {required dynamic onSuccess(String)?, required dynamic onError(CometChatException excep)?}) Future<void>
Messages for both user and group conversations can be marked as read using this method.
onTypingIndicator() Stream<String>
registerTokenForPushNotification(String token, {required dynamic onSuccess(String response)?, required dynamic onError(CometChatException excep)?}) Future<void>
Registers the obtained FCM Token which will be used by the CometChat server to send message via push notification.
rejectCall(String sessionID, String status, {required dynamic onSuccess(Call call)?, required dynamic onError(CometChatException excep)}) → void
removeCallListener(String listenerId) → dynamic
removeConnectionListener(String listenerId) → dynamic
Remove Connection Listener
removeGroupListener(String listenerId) → dynamic
Remove Group Listener
removeLoginListener(String listenerId) → dynamic
Remove Login Listener
removeMessageListener(String listenerId) → dynamic
To remove message listener
removeUserListener(String listenerId) → dynamic
Remove User Listener
sendCustomMessage(CustomMessage message, {required dynamic onSuccess(CustomMessage message)?, required dynamic onError(CometChatException excep)?}) Future<CustomMessage?>
send custom messages which are neither text nor media messages.
sendMediaMessage(MediaMessage mediaMessage, {required dynamic onSuccess(MediaMessage message)?, required dynamic onError(CometChatException excep)?}) Future<MediaMessage?>
send a media message like photos, videos & files.
sendMessage(TextMessage message, {required dynamic onSuccess(TextMessage message)?, required dynamic onError(CometChatException excep)?}) Future<TextMessage?>
To send a text message to a single user or group. returns the TextMessage with message id
sendTransientMessage(TransientMessage message, {required dynamic onSuccess()?, required dynamic onError(CometChatException excep)?}) → dynamic
Transient messages are messages that are sent in real-time only
setPlatformParams(String platform, String sdkVersion) Future<void>
setSource(String resource, String platform, String language) Future<void>
startTyping({String? receaverUid, String? receiverType}) → dynamic
method to inform the receiver that the logged in user has started typing.
tagConversation(String conversationWith, String conversationType, List<String> tags, {required dynamic onSuccess(Conversation conversation)?, required dynamic onError(CometChatException excep)?}) Future<Conversation?>
Tag a conversation
transferGroupOwnership({required String guid, required String uid, required dynamic onSuccess(String result)?, required dynamic onError(CometChatException excep)?}) Future<String?>
Transfer the ownership of any group if logged-in user is the owner of the group
unbanGroupMember({required String guid, required String uid, required dynamic onSuccess(String result)?, required dynamic onError(CometChatException excep)?}) Future<String?>
Only Admin or Moderators of the group can unban a previously banned member from the group
unblockUser(List<String>? uids, {required dynamic onSuccess(Map<String, dynamic> map)?, required dynamic onError(CometChatException excep)?}) Future<Map<String, dynamic>?>
Un-block a user from sending logged-in user any messages.
updateCurrentUserDetails(User user, {required dynamic onSuccess(User retUser)?, required dynamic onError(CometChatException excep)?}) Future<User?>
Updating a logged-in user is similar to updating a user
updateGroup({required Group group, required dynamic onSuccess(Group group)?, required dynamic onError(CometChatException excep)?}) Future<Group?>
update the group details
updateGroupMemberScope({required String guid, required String uid, required String scope, required dynamic onSuccess(String result)?, required dynamic onError(CometChatException excep)?}) Future<String?>
In order to change the scope of a group member
updateUser(User user, String apiKey, {required dynamic onSuccess(User retUser)?, required dynamic onError(CometChatException excep)?}) Future<User?>
Updating a user similar to creating a user should ideally be achieved at your backend using the Restful APIs