MarkerUpdates.update constructor
Implementation
MarkerUpdates.update(Set<Marker> previous, Set<Marker> current) {
final Map<MarkerId, Marker> oldMarkers = markerToMap(previous);
final Map<MarkerId, Marker> currMarkers = markerToMap(current);
final Set<MarkerId> oldIds = oldMarkers.keys.toSet();
final Set<MarkerId> currIds = currMarkers.keys.toSet();
final Set<MarkerId> toDelete = oldIds.difference(currIds);
final Set<Marker> toInsert = Set<Marker>.from(
currIds.difference(oldIds).map((MarkerId id) => currMarkers[id]).toSet(),
);
final Set<Marker> toUpdate = Set<Marker>.from(
currIds
.intersection(oldIds)
.map((MarkerId id) => currMarkers[id])
.where((Marker? x) => isChanged(x!, oldMarkers))
.toSet(),
);
insertSet = toInsert;
deleteSet = toDelete;
updateSet = toUpdate;
}