calculateAngle function

double calculateAngle(
  1. Offset origin,
  2. Offset target
)

Implementation

double calculateAngle(Offset origin, Offset target) {
  var dx = origin.dx - target.dx;
  var dy = origin.dy - target.dy;

  var theta = atan2(-dy, -dx);
  theta *= 180 / pi;
  theta += 90;
  if (theta < 0) theta += 360;

  return theta;
}