deleteConversation method

void deleteConversation(
  1. String conversationId
)

Deletes a conversation by its ID.

If the deleted conversation was the current one, the first remaining conversation becomes current, or null if none remain.

Implementation

void deleteConversation(String conversationId) {
  _conversations.removeWhere((conv) => conv.id == conversationId);
  if (_currentConversation?.id == conversationId) {
    _currentConversation =
        _conversations.isNotEmpty ? _conversations.first : null;
  }
  notifyListeners();
}