Rectangle<T extends num> constructor

const Rectangle<T extends num>(
  1. T left,
  2. T top,
  3. T width,
  4. T height
)

Create a rectangle spanned by (left, top) and (left+width, top+height).

The rectangle contains the points with x-coordinate between left and left + width, and with y-coordinate between top and top + height, both inclusive.

The width and height should be non-negative. If width or height are negative, they are clamped to zero.

If width and height are zero, the "rectangle" comprises only the single point (left, top).

Example:

var rectangle = const Rectangle(20, 50, 300, 600);
print(rectangle.left); // 20
print(rectangle.top); // 50
print(rectangle.right); // 320
print(rectangle.bottom); // 650

Legacy: New usages of Rectangle are discouraged. To learn more, check out the Rectangle class API docs.

Implementation

const Rectangle(this.left, this.top, T width, T height)
    : width = (width < 0)
          ? (width == double.negativeInfinity ? 0.0 : (-width * 0)) as dynamic
          : (width + 0 as dynamic), // Inline _clampToZero<num>.
      height = (height < 0)
          ? (height == double.negativeInfinity ? 0.0 : (-height * 0))
              as dynamic
          : (height + 0 as dynamic);