lookup method
Looks up a child Node at specified character offset
in this container.
Returns LookupResult. The result may contain found node or null
if
no node is found at specified offset.
LookupResult.offset is set to relative offset within returned child node
which points at the same character position in the document as the
original offset
.
Implementation
LookupResult lookup(int offset, {bool inclusive = false}) {
assert(offset >= 0 && offset <= length);
for (final node in children) {
final length = node.length;
if (offset < length || (inclusive && offset == length && (node.isLast))) {
return LookupResult(node, offset);
}
offset -= length;
}
return LookupResult(null, 0);
}