extractAt method

EasyText extractAt(
  1. int index,
  2. int length
)

Extract efficiently starting at index with specified length.

Implementation

EasyText extractAt(int index, int length) {
  assert(
    index >= 0 && index < this.length && (index + length <= this.length),
    'the index($index) or '
    'length($length) are not into the '
    'defined range of: 0 to ${this.length}',
  );
  // Extracts a substring starting from the specified index with the given length
  final EasyText left = splitAt(index)!
    // Example:
    //   Input: index = 5, length = 13
    //   Text: "This is an example text where we shows how works this"
    //
    //   Visual representation:
    //   "This |is an example| text where we shows how works this"
    //          ↑____________↑
    //          index 5, length 13
    //
    //   Returns: "is an example"
    //
    // The remaining parts of the original text are processed separately
    // in a new instance or data structure
    ..splitAt(length);
  final EasyText target = left;
  return target;
}