Conversation class

Represents a conversation between a user and an AI assistant.

A conversation contains multiple messages and maintains metadata such as title, creation date, and last update time.

Example:

final conversation = Conversation(
  id: 'conv_123',
  title: 'New Chat',
  messages: [],
  createdAt: DateTime.now(),
);
Annotations

Constructors

Conversation({required String id, required String title, required List<ChatMessage> messages, required DateTime createdAt, DateTime? updatedAt})
Creates a new conversation.
const
Conversation.fromJson(Map<String, dynamic> json)
Creates a Conversation from a JSON representation.
factory

Properties

createdAt → DateTime
When this conversation was created.
final
hashCode → int
The hash code for this object.
no setteroverride
id → String
Unique identifier for this conversation.
final
isEmpty → bool
Whether this conversation has no messages.
no setter
lastMessage → ChatMessage?
The last message in this conversation, if any.
no setter
messageCount → int
The total number of messages in this conversation.
no setter
messages → List<ChatMessage>
List of all messages in this conversation.
final
runtimeType → Type
A representation of the runtime type of the object.
no setterinherited
title → String
Display title for the conversation.
final
updatedAt → DateTime?
When this conversation was last updated.
final

Methods

addMessage(ChatMessage message) → Conversation
Adds a new message to this conversation.
copyWith({String? id, String? title, List<ChatMessage>? messages, DateTime? createdAt, DateTime? updatedAt}) → Conversation
Creates a copy of this conversation with some fields replaced.
noSuchMethod(Invocation invocation) → dynamic
Invoked when a nonexistent method or property is accessed.
inherited
toJson() → Map<String, dynamic>
Converts this conversation to a JSON representation.
toString() → String
A string representation of this object.
override
updateTitle(String newTitle) → Conversation
Updates the title of this conversation.

Operators

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