areContentsTheSame method

  1. @override
bool areContentsTheSame(
  1. int oldItemPosition,
  2. int newItemPosition
)
override

Called by the DiffUtil when it wants to check whether two items have the same data. DiffUtil uses this information to detect if the contents of an item has changed.

DiffUtil uses this method to check equality instead of == so that you can change its behavior depending on your UI. This method is called only if areItemsTheSame returns true for these items.

@param oldItemPosition The position of the item in the old list @param newItemPosition The position of the item in the new list which replaces the oldItem @return True if the contents of the items are the same or false if they are different.

Implementation

@override
bool areContentsTheSame(int oldItemPosition, int newItemPosition) {
  return true;
}