insert method
Insert data
at specified character index
with style style
.
Implementation
@override
void insert(int index, Object data, NotusStyle? style) {
assert(index >= 0 && (index <= length),
'Index out of bounds. Must be between 0 and $length, but got $index.');
final node = LeafNode(data);
if (index == length) {
insertAfter(node);
} else {
splitAt(index)!.insertBefore(node);
}
node.formatAndOptimize(style);
}