computeAlignment static method

double computeAlignment(
  1. int index,
  2. int itemCount
)

Converts item index to alignment (-1 to 1).

Implementation

static double computeAlignment(int index, int itemCount) {
  final relativeIndex = (index / (itemCount - 1)).clamp(0.0, 1.0);
  return (relativeIndex * 2) - 1;
}