removeAttr method

void removeAttr(
  1. UInlineAttr attr,
  2. int s,
  3. int e
)

Subtract the range [s, e) from every span of attr, splitting as needed.

Implementation

void removeAttr(UInlineAttr attr, int s, int e) {
  final List<UStyleSpan> result = <UStyleSpan>[];
  for (final UStyleSpan sp in spans) {
    if (sp.attr != attr || sp.end <= s || sp.start >= e) {
      result.add(sp);
      continue;
    }
    if (sp.start < s) result.add(UStyleSpan(start: sp.start, end: s, attr: attr, value: sp.value));
    if (sp.end > e) result.add(UStyleSpan(start: e, end: sp.end, attr: attr, value: sp.value));
  }
  spans
    ..clear()
    ..addAll(result);
}