indexAt method

int indexAt(
  1. double rotation,
  2. double pointerAngle
)

The index of the slice under the pointer at pointerAngle when the wheel is rotated by rotation.

Implementation

int indexAt(double rotation, double pointerAngle) {
  final double u = _positionUnderPointer(rotation, pointerAngle);
  for (int i = 0; i < length; i++) {
    if (u < offsets[i] + sweeps[i]) {
      if (sweeps[i] > 0) return i;
    }
  }
  // Rounding at the very end of the circle: the last visible slice.
  return sweeps.lastIndexWhere((s) => s > 0);
}