subspan method

SourceSpanWithContext 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

SourceSpanWithContext 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 SourceSpanWithContext(
      locations[0], locations[1], text.substring(start, end), context);
}