subspan method

SourceSpan subspan(
  1. int start, [
  2. int? end
])

Returns a span from start code units (inclusive) to end code units (exclusive) after the beginning of this span.

Implementation

SourceSpan subspan(int start, [int? end]) {
  RangeError.checkValidRange(start, end, length);
  if (start == 0 && (end == null || end == length)) return this;

  final locations = subspanLocations(this, start, end);
  return SourceSpan(locations[0], locations[1], text.substring(start, end));
}