overlaps method

bool overlaps(
  1. Rect other
)

Returns whether the provided rectangle overlaps this rectangle.

Rectangles exclude their right and bottom edges.

Example

final a = Rect.fromLTWH(0, 0, 2, 2);
final b = Rect.fromLTWH(1, 1, 2, 2);
print(a.overlaps(b)); // true

final c = Rect.fromLTWH(3, 3, 2, 2);
print(a.overlaps(c)); // false

Implementation

bool overlaps(Rect other) {
  return left < other.right &&
      right > other.left &&
      top < other.bottom &&
      bottom > other.top;
}