insertText method

Future<void> insertText(
  1. int index,
  2. String text, {
  3. Path? path,
  4. Node? node,
})

Insert text at the given index of the given Node or the Path.

Path and Node are mutually exclusive. One of these two parameters must have a value.

Implementation

Future<void> insertText(
  int index,
  String text, {
  Path? path,
  Node? node,
}) async {
  node ??= getNodeAtPath(path!);
  if (node == null) {
    assert(false, 'node is null');
    return;
  }
  return apply(
    transaction..insertText(node, index, text),
  );
}