codeUnitAtVisitor method

  1. @override
int? codeUnitAtVisitor(
  1. int index,
  2. Accumulator offset

Performs the check at each InlineSpan for if the index falls within the range of the span and returns the corresponding code unit. Returns null otherwise.

The offset parameter tracks the current index offset in the text buffer formed if the contents of the InlineSpan tree were concatenated together starting from the root InlineSpan.

This method should not be directly called. Use codeUnitAt instead.


int? codeUnitAtVisitor(int index, Accumulator offset) {
  final String? text = this.text;
  if (text == null) {
    return null;
  final int localOffset = index - offset.value;
  assert(localOffset >= 0);
  return localOffset < text.length ? text.codeUnitAt(localOffset) : null;