codeUnitAt method Null safety

int? codeUnitAt(
  1. int index
)

Returns the UTF-16 code unit at the given index in the flattened string.

This only accounts for the TextSpan.text values and ignores PlaceholderSpans.

Returns null if the index is out of bounds.

Implementation

int? codeUnitAt(int index) {
  if (index < 0)
    return null;
  final Accumulator offset = Accumulator();
  int? result;
  visitChildren((InlineSpan span) {
    result = span.codeUnitAtVisitor(index, offset);
    return result == null;
  });
  return result;
}