computeBoundary method

Rect computeBoundary(
  1. Rect result,
  2. Rect layoutRect
)

Implementation

Rect computeBoundary(Rect result, Rect layoutRect) {
  if (_computeHorizontalBoundary) {
    //move right
    if (doubleCompare(result.left, layoutRect.left) >= 0) {
      result = Rect.fromLTWH(
          layoutRect.left, result.top, result.width, result.height);
    }

    ///move left
    if (doubleCompare(result.right, layoutRect.right) <= 0) {
      result = Rect.fromLTWH(layoutRect.right - result.width, result.top,
          result.width, result.height);
    }
  }

  if (_computeVerticalBoundary) {
    //move down
    if (doubleCompare(result.bottom, layoutRect.bottom) <= 0) {
      result = Rect.fromLTWH(result.left, layoutRect.bottom - result.height,
          result.width, result.height);
    }

    //move up
    if (doubleCompare(result.top, layoutRect.top) >= 0) {
      result = Rect.fromLTWH(
          result.left, layoutRect.top, result.width, result.height);
    }
  }

  _computeHorizontalBoundary =
      doubleCompare(result.left, layoutRect.left) <= 0 &&
          doubleCompare(result.right, layoutRect.right) >= 0;

  _computeVerticalBoundary = doubleCompare(result.top, layoutRect.top) <= 0 &&
      doubleCompare(result.bottom, layoutRect.bottom) >= 0;
  return result;
}