codeUnitAtVisitor method Null safety

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

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.

Implementation

@override
int? codeUnitAtVisitor(int index, Accumulator offset) {
  if (text == null) {
    return null;
  }
  if (index - offset.value < text!.length) {
    return text!.codeUnitAt(index - offset.value);
  }
  offset.increment(text!.length);
  return null;
}