hasAttributionAt method

bool hasAttributionAt(
  1. int offset, {
  2. Attribution? attribution,
})

Returns true if the given offset has the given attribution.

If the given attribution is null, returns true if any attribution exists at the given offset.

Implementation

bool hasAttributionAt(
  int offset, {
  Attribution? attribution,
}) {
  SpanMarker? markerBefore = _getStartingMarkerAtOrBefore(offset, attribution: attribution);
  if (markerBefore == null) {
    return false;
  }
  SpanMarker? markerAfter = _getEndingMarkerAtOrAfter(markerBefore.offset, attribution: attribution);
  if (markerAfter == null) {
    throw Exception('Found an open-ended attribution. It starts with: $markerBefore');
  }

  return (markerBefore.offset <= offset) && (offset <= markerAfter.offset);
}