normalize method
Implementation
Offset normalize() {
// Find the maximum absolute value between x and y
double maxComponent = math.max(dx.abs(), dy.abs());
// Avoid division by zero
if (maxComponent == 0) {
return const Offset(0, 0);
}
// Normalize the offset to the range -1 to 1
double normalizedX = dx / maxComponent;
double normalizedY = dy / maxComponent;
return Offset(normalizedX, normalizedY);
}