ChatMessage class
Represents a chat message with support for replies and system messages.
A message can be either a regular user message, a system message, or a deleted message. Messages can also be replies to other messages, indicated by replyToMessageId and replyToSnapshot.
Example:
final message = ChatMessage(
id: 'msg-1',
chatId: 'chat-123',
authorId: 'user-456',
authorDisplayName: 'John Doe',
text: 'Hello!',
createdAt: DateTime.now(),
);
Constructors
- ChatMessage({required String id, required String chatId, required String authorId, required String authorDisplayName, String? authorAvatarUrl, required String text, required DateTime createdAt, DateTime? updatedAt, bool isSystem = false, bool isDeleted = false, String? replyToMessageId, ChatReplySnapshot? replyToSnapshot})
-
Creates a new ChatMessage.
const
Properties
-
Optional avatar URL for the message author.
final
-
Display name of the user who created this message.
final
-
ID of the user who created this message.
final
- chatId → String
-
ID of the chat this message belongs to.
final
- createdAt → DateTime
-
Date and time when the message was created.
final
- hashCode → int
-
The hash code for this object.
no setteroverride
- id → String
-
Unique identifier for this message.
final
- isDeleted → bool
-
Whether this message has been deleted (soft delete).
final
- isReply → bool
-
Whether this message is a reply to another message.
no setter
- isSystem → bool
-
Whether this is a system message (e.g., "User joined").
final
- replyToMessageId → String?
-
ID of the message this is replying to, if any.
final
- replyToSnapshot → ChatReplySnapshot?
-
Snapshot of the message being replied to, if any.
final
- runtimeType → Type
-
A representation of the runtime type of the object.
no setterinherited
- text → String
-
The text content of the message.
final
- updatedAt → DateTime?
-
Optional date and time when the message was last updated.
final
Methods
-
copyWith(
{String? id, String? chatId, String? authorId, String? authorDisplayName, String? authorAvatarUrl, String? text, DateTime? createdAt, DateTime? updatedAt, bool? isSystem, bool? isDeleted, String? replyToMessageId, ChatReplySnapshot? replyToSnapshot}) → ChatMessage - Creates a copy of this message with the given fields replaced with new values.
-
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.
override