Rectangle.fromCenter constructor

Rectangle.fromCenter({
  1. required Vector2 center,
  2. required Vector2 size,
})

Constructs a Rectangle from a center point and a size.

Implementation

factory Rectangle.fromCenter({
  required Vector2 center,
  required Vector2 size,
}) {
  final halfSize = size / 2;
  return Rectangle.fromPoints(
    center - halfSize,
    center + halfSize,
  );
}