ChatMessage class abstract

A chat message with text, attachments, reactions, and metadata.

Equality is id-based so a Set<ChatMessage> deduplicates by id even when an in-flight version (pending) and a server-confirmed version (with receipt) of the same message coexist briefly.

Available extensions
Annotations
  • @Freezed.new(equal: false)

Constructors

ChatMessage({required String id, required String from, required DateTime timestamp, String? text, @Default.new(MessageType.regular) MessageType messageType, String? attachmentUrl, String? referencedMessageId, String? clientMessageId, String? reaction, String? reply, Map<String, dynamic>? metadata, ReceiptStatus? receipt, @Default.new(false) bool isEdited, @Default.new(false) bool isDeleted, @Default.new(false) bool isForwarded, @Default.new(false) bool isStarred, @Default.new(false) bool isSystem, String? mimeType, String? fileName, String? fileSize, String? thumbnailUrl})
const
factory

Properties

attachmentUrl String?
no setterinherited
clientMessageId String?
Echo of the client-supplied idempotency key sent with the message (see ChatMessagesApi.send's clientMessageId). The backend round-trips it inside the response metadata.clientMessageId; the SDK lifts it out to this field so it can reconcile the optimistic temporary message with the server-assigned id. null when the sender did not supply one (e.g. messages from other users).
no setterinherited
copyWith → $ChatMessageCopyWith<ChatMessage>
Create a copy of ChatMessage with the given fields replaced by the non-null parameter values.
no setterinherited
fileName String?
no setterinherited
fileSize String?
no setterinherited
forwardInfo ForwardInfo?
Extracts forwarding metadata if this is a forwarded message. Tries metadata keys first, falls back to message-level fields.
no setter
from String
no setterinherited
hashCode int
The hash code for this object.
no setteroverride
id String
no setterinherited
isDeleted bool
no setterinherited
isEdited bool
no setterinherited
isForwarded bool
no setterinherited
isStarred bool
no setterinherited
isSystem bool
no setterinherited
messageType MessageType
no setterinherited
metadata Map<String, dynamic>?
no setterinherited
mimeType String?
no setterinherited
reaction String?
no setterinherited
receipt ReceiptStatus?
no setterinherited
referencedMessageId String?
no setterinherited
reply String?
no setterinherited
runtimeType Type
A representation of the runtime type of the object.
no setterinherited
text String?
no setterinherited
thumbnailUrl String?
no setterinherited
timestamp DateTime
no setterinherited

Methods

map<TResult extends Object?>(TResult $default(_ChatMessage value)) → TResult

Available on ChatMessage, provided by the ChatMessagePatterns extension

A switch-like method, using callbacks.
mapOrNull<TResult extends Object?>(TResult? $default(_ChatMessage value)?) → TResult?

Available on ChatMessage, provided by the ChatMessagePatterns extension

A variant of map that fallback to returning null.
maybeMap<TResult extends Object?>(TResult $default(_ChatMessage value)?, {required TResult orElse()}) → TResult

Available on ChatMessage, provided by the ChatMessagePatterns extension

A variant of map that fallback to returning orElse.
maybeWhen<TResult extends Object?>(TResult $default(String id, String from, DateTime timestamp, String? text, MessageType messageType, String? attachmentUrl, String? referencedMessageId, String? clientMessageId, String? reaction, String? reply, Map<String, dynamic>? metadata, ReceiptStatus? receipt, bool isEdited, bool isDeleted, bool isForwarded, bool isStarred, bool isSystem, String? mimeType, String? fileName, String? fileSize, String? thumbnailUrl)?, {required TResult orElse()}) → TResult

Available on ChatMessage, provided by the ChatMessagePatterns extension

A variant of when that fallback to an orElse callback.
noSuchMethod(Invocation invocation) → dynamic
Invoked when a nonexistent method or property is accessed.
inherited
toString() String
A string representation of this object.
override
when<TResult extends Object?>(TResult $default(String id, String from, DateTime timestamp, String? text, MessageType messageType, String? attachmentUrl, String? referencedMessageId, String? clientMessageId, String? reaction, String? reply, Map<String, dynamic>? metadata, ReceiptStatus? receipt, bool isEdited, bool isDeleted, bool isForwarded, bool isStarred, bool isSystem, String? mimeType, String? fileName, String? fileSize, String? thumbnailUrl)) → TResult

Available on ChatMessage, provided by the ChatMessagePatterns extension

A switch-like method, using callbacks.
whenOrNull<TResult extends Object?>(TResult? $default(String id, String from, DateTime timestamp, String? text, MessageType messageType, String? attachmentUrl, String? referencedMessageId, String? clientMessageId, String? reaction, String? reply, Map<String, dynamic>? metadata, ReceiptStatus? receipt, bool isEdited, bool isDeleted, bool isForwarded, bool isStarred, bool isSystem, String? mimeType, String? fileName, String? fileSize, String? thumbnailUrl)?) → TResult?

Available on ChatMessage, provided by the ChatMessagePatterns extension

A variant of when that fallback to returning null

Operators

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