IntRect.fromCenter constructor

IntRect.fromCenter({
  1. required IntOffset center,
  2. required int width,
  3. required int height,
})

Creates a new IntRect from center point, width, and height values.

center The IntOffset of the center point. width The width of the rectangle. height The height of the rectangle.

Implementation

factory IntRect.fromCenter({
  required final IntOffset center,
  required final int width,
  required final int height,
}) {
  return IntRect(
    center.x - width ~/ 2,
    center.y - height ~/ 2,
    width,
    height,
  );
}