getRelativeOffset static method

Offset? getRelativeOffset(
  1. RenderStyle renderStyle
)

Implementation

static Offset? getRelativeOffset(RenderStyle renderStyle) {
    CSSLengthValue left = renderStyle.left;
    CSSLengthValue right = renderStyle.right;
    CSSLengthValue top = renderStyle.top;
    CSSLengthValue bottom = renderStyle.bottom;
    if (renderStyle.position == CSSPositionType.relative) {
      double? dx;
      double? dy;

      if (left.isNotAuto) {
        dx = renderStyle.left.computedValue;
      } else if (right.isNotAuto) {
        double _dx = renderStyle.right.computedValue;
        dx = -_dx;
      }

      if (top.isNotAuto) {
        dy = renderStyle.top.computedValue;
      } else if (bottom.isNotAuto) {
        double _dy = renderStyle.bottom.computedValue;
        dy = -_dy;
      }

      if (dx != null || dy != null) {
        return Offset(dx ?? 0, dy ?? 0);
      }
    }
    return null;
  }