hashEntities<T extends DatumEntity> method

String hashEntities<T extends DatumEntity>(
  1. List<T> entities
)

Generates a SHA-256 hash from a list of entities.

The entities are sorted by ID before serialization to ensure a consistent order, resulting in a stable hash for the same set of data.

Implementation

String hashEntities<T extends DatumEntity>(List<T> entities) {
  final sorted = List<T>.from(entities)..sort((a, b) => a.id.compareTo(b.id));
  final jsonList = sorted.map((e) => e.toDatumMap(target: MapTarget.remote)).toList();
  return _hashJson(jsonList);
}