splitAt method

EasyText? splitAt(
  1. int index, [
  2. bool asDirty = false
])

Splits this EasyText at specified offset

  • asDirty tells to this method to mark the splitted node part as dirty before inserting again into the EasTextList parent

Returns the inserted EasyText object

Implementation

EasyText? splitAt(int index, [bool asDirty = false]) {
  assert(
      index >= 0 && index <= length,
      'offset $index does '
      'not satisfy the range '
      'of this text => 0 to $length');
  if (index == 0) return this;
  if (index == length) return isLast ? null : next;

  final EasyText split = EasyText(
    text: after(index),
    styles: styles.copy(),
  );
  text = before(index);
  if (asDirty) {
    split._dirty = true;
  }
  insertAfter(split);
  return split;
}