addAgentMessage method
Implementation
void addAgentMessage(ChatMessage message) {
final messageId = _getMessageId(message);
if (!_messageCache.containsKey(messageId)) {
if (paginationConfig.reverseOrder) {
// In reverse order (newest first), new messages go at the beginning (index 0)
// With ListView.builder(reverse: true), this puts newest messages at the bottom
_messages.insert(0, message);
} else {
// In chronological order (oldest first), new messages go at the end
// With ListView.builder(reverse: false), this puts newest messages at the bottom
_messages.add(message);
}
_messageCache[messageId] = message;
notifyListeners();
// After adding a message, scroll to bottom
//_scrollToBottomAfterRender();
}
}