childAtPosition method Null safety

RenderEditableBox childAtPosition(
  1. TextPosition position
)

Implementation

RenderEditableBox childAtPosition(TextPosition position) {
  assert(firstChild != null);

  final targetNode = _container.queryChild(position.offset, false).node;

  var targetChild = firstChild;
  while (targetChild != null) {
    if (targetChild.getContainer() == targetNode) {
      break;
    }
    final newChild = childAfter(targetChild);
    if (newChild == null) {
      break;
    }
    targetChild = newChild;
  }
  if (targetChild == null) {
    throw 'targetChild should not be null';
  }
  return targetChild;
}