writeTextRange method

void writeTextRange(
  1. int start,
  2. int end
)

Implementation

void writeTextRange(int start, int end) {
  if (end <= start) {
    return;
  }

  final text = source.substring(start, end);
  final nodes = _stack.last.children;

  // If the previous node is text too, just append.
  if (nodes.isNotEmpty && nodes.last is Text) {
    final textNode = nodes.last as Text;
    nodes[nodes.length - 1] = Text('${textNode.text}$text');
  } else {
    nodes.add(Text(text));
  }
}