rotatePoint static method

Offset rotatePoint(
  1. Offset point,
  2. Offset center,
  3. double angle
)

Rotates a point around a center by the given angle.

point is the point to rotate. center is the center of rotation. angle is the angle in radians.

Implementation

static Offset rotatePoint(Offset point, Offset center, double angle) {
  final cosA = math.cos(angle);
  final sinA = math.sin(angle);

  final dx = point.dx - center.dx;
  final dy = point.dy - center.dy;

  final rotatedX = dx * cosA - dy * sinA;
  final rotatedY = dx * sinA + dy * cosA;

  return Offset(center.dx + rotatedX, center.dy + rotatedY);
}