bestTextAngle static method
Suggest the best text angle for a string that sits on a given line, by using the start and end points of that line.
Implementation
static double bestTextAngle(Offset from, Offset to) {
var angle = math.atan2(
to.dy - from.dy,
to.dx - from.dx,
);
if (angle < -math.pi / 2 || angle > math.pi / 2) {
angle = math.atan2(
from.dy - to.dy,
from.dx - to.dx,
);
}
return angle;
}