extractAt method
Extract efficiently starting at index with specified length.
Extracts a substring starting from the specified index with the given length
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
Implementation
EasyText extractAt(int index, int length, [bool asDirty = false]) {
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}',
);
final EasyText? split1 = splitAt(index, asDirty);
split1?.splitAt(length, asDirty)?._dirty = false;
return split1!.._dirty = asDirty;
}