onItemRemoved method

  1. @override
void onItemRemoved(
  1. Conversation item,
  2. List<Conversation> updatedList
)
override

Called when a conversation is removed from the list.

Implementation

@override
void onItemRemoved(Conversation item, List<Conversation> updatedList) {
  // Get the index BEFORE removing from map (map still has old index)
  final removedIndex = _conversationIndexMap[item.conversationId];

  // Remove from map
  _removeFromIndexMap(item.conversationId);

  // Shift indices for items that were after the removed item
  if (removedIndex != null) {
    _shiftIndicesAfterRemoval(removedIndex);
  }

  if (!isClosed) {
    add(_ListItemRemoved(updatedList));
  }
}