compareAnnotations function

void compareAnnotations({
  1. required List<String> oldAnnotations,
  2. required List<String> newAnnotations,
  3. required void onRemoved(
    1. String
    ),
  4. required void onAdded(
    1. String
    ),
})

Compares two lists of annotations and invokes callbacks for added and removed annotations.

oldAnnotations The list of annotations from the old version. newAnnotations The list of annotations from the new version. onRemoved Callback invoked for annotations present in oldAnnotations but missing in newAnnotations. onAdded Callback invoked for annotations present in newAnnotations but missing in oldAnnotations.

Implementation

void compareAnnotations({
  required List<String> oldAnnotations,
  required List<String> newAnnotations,
  required void Function(String) onRemoved,
  required void Function(String) onAdded,
}) {
  for (final annotation in oldAnnotations) {
    if (!newAnnotations.contains(annotation)) {
      onRemoved(annotation);
    }
  }
  for (final annotation in newAnnotations) {
    if (!oldAnnotations.contains(annotation)) {
      onAdded(annotation);
    }
  }
}