union method
Returns the minimal rectangle that contains both this and other.
Implementation
Rectangle union(Rectangle other) {
if (isEmpty) return other;
if (other.isEmpty) return this;
return Rectangle(
minX: math.min(minX, other.minX),
minY: math.min(minY, other.minY),
maxX: math.max(maxX, other.maxX),
maxY: math.max(maxY, other.maxY),
);
}