getBlockRect method

Rect getBlockRect({
  1. bool shiftWithBaseOffset = false,
})

Implementation

Rect getBlockRect({
  bool shiftWithBaseOffset = false,
}) {
  final parentBox = containerKey.currentContext?.findRenderObject();
  final childBox = blockComponentKey.currentContext?.findRenderObject();
  if (parentBox is RenderBox && childBox is RenderBox) {
    final offset = childBox.localToGlobal(Offset.zero, ancestor: parentBox);
    final size = parentBox.size;
    if (shiftWithBaseOffset) {
      return offset & (size - offset as Size);
    }
    return Offset.zero & (size - offset as Size);
  }
  return Rect.zero;
}