Rectangle<T extends num> 构造函数
- T left,
- T top,
- T width,
- T height,
创建一个由 (left, top) 和 (left+width, top+height) 确定的矩形。
矩形包含 x 坐标在 left 和 left + width 之间,y 坐标在 top 和 top + height 之间的点,两者均包含。
width 和 height 应该是非负的。如果 width 或 height 为负,它们将被限制为零。
如果 width 和 height 都为零,则“矩形”仅包含单个点 (left, top)。
示例
var rectangle = const Rectangle(20, 50, 300, 600);
print(rectangle.left); // 20
print(rectangle.top); // 50
print(rectangle.right); // 320
print(rectangle.bottom); // 650
实现
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);