Rectangle.fromCenter constructor

Rectangle.fromCenter({
  1. required Point center,
  2. required double width,
  3. required double height,
})

Create a rectangle from center point, width, and height

Implementation

factory Rectangle.fromCenter({
  required Point center,
  required double width,
  required double height,
}) {
  return Rectangle(
    x: center.x - width / 2,
    y: center.y - height / 2,
    width: width,
    height: height,
  );
}