operator - method

OffsetBase operator -(
  1. OffsetBase other
)

Binary subtraction operator for Size.

Subtracting a Size from a Size returns the Offset that describes how much bigger the left-hand-side operand is than the right-hand-side operand. Adding that resulting Offset to the Size that was the right-hand-side operand would return a Size equal to the Size that was the left-hand-side operand. (i.e. if sizeA - sizeB -> offsetA, then offsetA + sizeB -> sizeA)

Subtracting an Offset from a Size returns the Size that is smaller than the Size operand by the difference given by the Offset operand. In other words, the returned Size has a width consisting of the width of the left-hand-side operand minus the Offset.dx dimension of the right-hand-side operand, and a height consisting of the height of the left-hand-side operand minus the Offset.dy dimension of the right-hand-side operand.

Implementation

OffsetBase operator -(OffsetBase other) {
  if (other is Size) {
    return Offset(width - other.width, height - other.height);
  }
  if (other is Offset) {
    return Size(width - other.dx, height - other.dy);
  }
  throw ArgumentError(other);
}