applyRelativeOffset static method

void applyRelativeOffset(
  1. Offset? relativeOffset,
  2. RenderBox renderBox
)

Implementation

static void applyRelativeOffset(Offset? relativeOffset, RenderBox renderBox) {
  RenderLayoutParentData? boxParentData = renderBox.parentData as RenderLayoutParentData?;

  if (boxParentData != null) {
    Offset? styleOffset;
    // Text node does not have relative offset
    if (renderBox is RenderBoxModel) {
      styleOffset = getRelativeOffset(renderBox.renderStyle);
    }

    if (relativeOffset != null) {
      if (styleOffset != null) {
        boxParentData.offset = relativeOffset.translate(styleOffset.dx, styleOffset.dy);
      } else {
        boxParentData.offset = relativeOffset;
      }
    } else {
      boxParentData.offset = styleOffset!;
    }
  }
}