computeBoundary method
Implementation
Rect computeBoundary(Rect result, Rect layoutRect) {
if (_computeHorizontalBoundary) {
//move right
if (result.left.greaterThanOrEqualTo(layoutRect.left)) {
result = Rect.fromLTWH(
layoutRect.left, result.top, result.width, result.height);
}
///move left
if (result.right.lessThanOrEqualTo(layoutRect.right)) {
result = Rect.fromLTWH(layoutRect.right - result.width, result.top,
result.width, result.height);
}
}
if (_computeVerticalBoundary) {
//move down
if (result.bottom.lessThanOrEqualTo(layoutRect.bottom)) {
result = Rect.fromLTWH(result.left, layoutRect.bottom - result.height,
result.width, result.height);
}
//move up
if (result.top.greaterThanOrEqualTo(layoutRect.top)) {
result = Rect.fromLTWH(
result.left, layoutRect.top, result.width, result.height);
}
}
_computeHorizontalBoundary =
result.left.lessThanOrEqualTo(layoutRect.left) &&
result.right.greaterThanOrEqualTo(layoutRect.right);
_computeVerticalBoundary = result.top.lessThanOrEqualTo(layoutRect.top) &&
result.bottom.greaterThanOrEqualTo(layoutRect.bottom);
return result;
}