intersection method

Bounds? intersection(
  1. Bounds other
)

Returns the intersection with another bounds.

Implementation

Bounds? intersection(Bounds other) {
  if (!intersects(other)) return null;

  return Bounds.fromLTRB(
    left > other.left ? left : other.left,
    top > other.top ? top : other.top,
    right < other.right ? right : other.right,
    bottom < other.bottom ? bottom : other.bottom,
  );
}