getOffsetToAncestor method

Offset getOffsetToAncestor(
  1. Offset point,
  2. RenderBoxModel ancestor, {
  3. bool excludeScrollOffset = false,
})

Implementation

Offset getOffsetToAncestor(Offset point, RenderBoxModel ancestor, {bool excludeScrollOffset = false}) {
  double ancestorBorderTop = ancestor.renderStyle.borderTopWidth?.computedValue ?? 0;
  double ancestorBorderLeft = ancestor.renderStyle.borderLeftWidth?.computedValue ?? 0;
  Offset ancestorBorderWidth = Offset(ancestorBorderLeft, ancestorBorderTop);

  return getLayoutTransformTo(this, ancestor, excludeScrollOffset: excludeScrollOffset) + point - ancestorBorderWidth;
}