BaseMessage class

Represents a basic chat message.

Android Reference: com.cometchat.chat.models.BaseMessage

This class serves as a base class for more specific types of messages, such as text messages, media messages, action messages, etc.

Each BaseMessage includes a variety of properties, including sender information, receiver information, timestamps, and more. Among the properties are some specifically designed for more advanced message types, such as unreadRepliesCount for counting unread reply messages, and reactions for storing reactions added to the message.

Inheritance
Implementers

Constructors

BaseMessage({int id = 0, String muid = '', User? sender, AppEntity? receiver, required String receiverUid, required String type, required String receiverType, String category = '', DateTime? sentAt, DateTime? deliveredAt, DateTime? readAt, Map<String, dynamic>? metadata, DateTime? readByMeAt, DateTime? deliveredToMeAt, DateTime? deletedAt, DateTime? editedAt, String? deletedBy, String? editedBy, DateTime? updatedAt, String? conversationId, int parentMessageId = 0, int replyCount = 0, bool threadSubscribed = false, DateTime? pinnedAt, String? pinnedBy, DateTime? savedAt, int unreadRepliesCount = 0, List<User> mentionedUsers = const [], List<ReactionCount> reactions = const [], bool hasMentionedMe = false, BaseMessage? quotedMessage, int quotedMessageId = 0, Map<String, dynamic>? rawMessage})
Constructs a new BaseMessage instance.
BaseMessage.fromMap(dynamic map)
Creates a new BaseMessage instance from a map.
factory

Properties

category String
The category of message (message, action, call, custom, etc.). Android: String category (reference type, can be null)
getter/setter pair
conversationId String?
The conversation ID this message belongs to. Android: String conversationId (reference type, can be null)
getter/setter pair
deletedAt DateTime?
Timestamp when the message was deleted. Android: long deletedAt (primitive, 0 = not set)
getter/setter pair
deletedBy String?
UID of the user who deleted the message. Android: String deletedBy (reference type, can be null)
getter/setter pair
deliveredAt DateTime?
Timestamp when the message was delivered. Android: long deliveredAt (primitive, 0 = not set)
getter/setter pair
deliveredToMeAt DateTime?
Timestamp when the message was delivered to the logged-in user. Android: long deliveredToMeAt (primitive, 0 = not set)
getter/setter pair
editedAt DateTime?
Timestamp when the message was edited. Android: long editedAt (primitive, 0 = not set)
getter/setter pair
editedBy String?
UID of the user who edited the message. Android: String editedBy (reference type, can be null)
getter/setter pair
hashCode int
The hash code for this object.
no setterinherited
hasMentionedMe bool
Whether the logged-in user is mentioned in this message. Android: boolean hasMentionedMe (primitive, defaults to false) Note: In Android, this is computed by checking if logged-in user UID is in the mentions map. Flutter computes this the same way in the mapper.
getter/setter pair
id int
Unique identifier for the message. Android: long id (primitive, defaults to 0)
getter/setter pair
mentionedUsers List<User>
List of users mentioned in this message. Android: List<User> mentionedUser (initialized to empty ArrayList)
getter/setter pair
metadata Map<String, dynamic>?
Custom metadata attached to the message. Android: JSONObject metadata (reference type, can be null)
getter/setter pair
muid String
Developer-set unique identifier. Android: String muid (reference type, can be null)
getter/setter pair
parentMessageId int
Parent message ID for threaded messages. Android: long parentMessageId (primitive, defaults to 0)
getter/setter pair
pinnedAt DateTime?
When this message was pinned to its conversation (pin & save). null = not pinned. Present-only-when-set on the wire — absence means "not pinned", never an error.
getter/setter pair
pinnedBy String?
UID of the member who pinned this message, or the app_system sentinel when the pin was placed by an admin surface (API key / dashboard). null whenever pinnedAt is null.
getter/setter pair
quotedMessage BaseMessage?
The quoted message (for reply messages). Android: BaseMessage quotedMessage (reference type, can be null)
getter/setter pair
quotedMessageId int
The ID of the quoted message. Android: long quotedMessageId (primitive, defaults to 0)
getter/setter pair
rawMessage Map<String, dynamic>?
The raw JSON message for passthrough of unmapped fields. Android: JSONObject rawMessage (reference type, can be null)
getter/setter pair
reactions List<ReactionCount>
List of reactions on this message. Android: List<ReactionCount> reactions (initialized to empty ArrayList)
getter/setter pair
readAt DateTime?
Timestamp when the message was read. Android: long readAt (primitive, 0 = not set)
getter/setter pair
readByMeAt DateTime?
Timestamp when the message was read by the logged-in user. Android: long readByMeAt (primitive, 0 = not set)
getter/setter pair
receiver AppEntity?
The receiver of the message (User or Group). Android: AppEntity receiver (reference type, can be null)
getter/setter pair
receiverType String
The type of receiver (user or group). Android: String receiverType (required in constructor)
getter/setter pair
receiverUid String
The UID of the receiver. Android: String receiverUid (required in constructor)
getter/setter pair
replyCount int
Number of replies to this message. Android: int replyCount (primitive, defaults to 0)
getter/setter pair
runtimeType Type
A representation of the runtime type of the object.
no setterinherited
savedAt DateTime?
When the logged-in user saved (bookmarked) this message. Per-viewer: two users see different values for the same message. null = not saved by me.
getter/setter pair
sender User?
The sender of the message. Android: User sender (reference type, can be null)
getter/setter pair
sentAt DateTime?
Timestamp when the message was sent. Android: long sentAt (primitive, 0 = not set)
getter/setter pair
threadSubscribed bool
Whether the logged-in user is subscribed to this message's thread (thread subscription — reply-notification follow state).
getter/setter pair
type String
The type of message (text, image, video, etc.). Android: String type (required in constructor)
getter/setter pair
unreadRepliesCount int
Number of unread replies to this message. Android: int unreadRepliesCount (primitive, defaults to 0)
getter/setter pair
updatedAt DateTime?
Timestamp when the message was last updated. Android: long updatedAt (primitive, 0 = not set)
getter/setter pair

Methods

noSuchMethod(Invocation invocation) → dynamic
Invoked when a nonexistent method or property is accessed.
inherited
toJson() Map<String, dynamic>
Generates a map representing the BaseMessage.
toString() String
A string representation of this object.
inherited

Operators

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