endRotationFor method

double endRotationFor({
  1. required double startRotation,
  2. required int index,
  3. required double fraction,
  4. required double pointerAngle,
  5. required int fullTurns,
  6. bool clockwise = true,
})

The end rotation for a spin starting at startRotation that turns at least fullTurns whole turns in the given direction and stops with fraction of slice index under the pointer.

Implementation

double endRotationFor({
  required double startRotation,
  required int index,
  required double fraction,
  required double pointerAngle,
  required int fullTurns,
  bool clockwise = true,
}) {
  final double target = restingRotationFor(index, fraction, pointerAngle);
  final double phase = startRotation % (2 * pi);
  if (clockwise) {
    final double diff = (target - phase) % (2 * pi);
    return startRotation + fullTurns * 2 * pi + diff;
  }
  final double diff = (phase - target) % (2 * pi);
  return startRotation - fullTurns * 2 * pi - diff;
}