createNewConversation method

void createNewConversation()

Creates a new conversation and makes it the current one.

The new conversation will have:

  • A unique ID based on current timestamp
  • Default title "New Chat"
  • Empty message list
  • Current timestamp as creation time

Implementation

void createNewConversation() {
  final conversation = Conversation(
    id: DateTime.now().millisecondsSinceEpoch.toString(),
    title: 'New Chat',
    messages: const [],
    createdAt: DateTime.now(),
  );
  _conversations.insert(0, conversation);
  _currentConversation = conversation;
  _error = '';
  notifyListeners();
}