ChatMessage class

Represents a message in a chat conversation.

This class encapsulates the properties and behavior of a chat message, including its unique identifier, origin (user or LLM), text content, and any attachments.

Constructors

ChatMessage({required MessageOrigin origin, required String? text, required Iterable<Attachment> attachments})
Constructs a ChatMessage instance.
ChatMessage.fromJson(Map<String, dynamic> map)
Converts a JSON map representation to a ChatMessage.
factory
ChatMessage.llm()
Factory constructor for creating an LLM-originated message.
factory
ChatMessage.user(String text, Iterable<Attachment> attachments)
Factory constructor for creating a user-originated message.
factory

Properties

attachments Iterable<Attachment>
Any attachments associated with the message.
final
hashCode int
The hash code for this object.
no setterinherited
origin MessageOrigin
The origin of the message (user or LLM).
final
runtimeType Type
A representation of the runtime type of the object.
no setterinherited
text String?
Text content of the message.
getter/setter pair

Methods

append(String text) → void
Appends additional text to the existing message content.
noSuchMethod(Invocation invocation) → dynamic
Invoked when a nonexistent method or property is accessed.
inherited
toJson() Map<String, dynamic>
Converts a ChatMessage to a JSON map representation.
toString() String
A string representation of this object.
override

Operators

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