toAlignment method

Alignment toAlignment(
  1. Rect rect
)

Alignment goes from (-1, -1) to (1, 1) This method converts an Offset with (0,0) to (1,1) to an Alignment

Implementation

Alignment toAlignment(Rect rect) {
  return Alignment(
    (dx / rect.size.width) * 2 - 1,
    (dy / rect.size.height) * 2 - 1,
  );
}