childAtPosition method

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.container == targetNode) {
      break;
    }
    final newChild = childAfter(targetChild);
    if (newChild == null) {
      //  At start of document fails to find the position
      targetChild = childAtOffset(const Offset(0, 0));
      break;
    }
    targetChild = newChild;
  }
  if (targetChild == null) {
    throw 'targetChild should not be null';
  }
  return targetChild;
}