hashEntities<T extends DatumEntityInterface> method
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.
This is O(n log n) (sort) plus a full serialization of the whole set on every call. For large datasets synced frequently, prefer hashEntitiesUnordered (no sort) or DatumRollingHash (O(1) incremental updates).
Implementation
String hashEntities<T extends DatumEntityInterface>(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);
}