childAtOffset method Null safety

RenderEditableBox? childAtOffset(
  1. Offset offset
)

Implementation

RenderEditableBox? childAtOffset(Offset offset) {
  assert(firstChild != null);
  _resolvePadding();

  if (offset.dy <= _resolvedPadding!.top) {
    return firstChild;
  }
  if (offset.dy >= size.height - _resolvedPadding!.bottom) {
    return lastChild;
  }

  var child = firstChild;
  final dx = -offset.dx;
  var dy = _resolvedPadding!.top;
  while (child != null) {
    if (child.size.contains(offset.translate(dx, -dy))) {
      return child;
    }
    dy += child.size.height;
    child = childAfter(child);
  }
  throw 'No child';
}