union method
Returns the bounding box containing both rectangles.
Implementation
Rect union(Rect other) {
final x1 = x < other.x ? x : other.x;
final y1 = y < other.y ? y : other.y;
final x2 = right > other.right ? right : other.right;
final y2 = bottom > other.bottom ? bottom : other.bottom;
return Rect(x1, y1, x2 - x1, y2 - y1);
}