animateLoopRotation method

void animateLoopRotation({
  1. required List<double> angles,
  2. required int repeatCount,
  3. bool normalizeOnFinish = true,
  4. List<Duration>? pauseDuration,
  5. List<Duration>? rotationDuration,
  6. List<Curve>? curves,
  7. VoidCallback? onFinish,
})

Implementation

void animateLoopRotation({
  required List<double> angles,
  required int repeatCount,
  bool normalizeOnFinish = true,
  List<Duration>? pauseDuration,
  List<Duration>? rotationDuration,
  List<Curve>? curves,
  VoidCallback? onFinish,
}) async {
  int currentRepetition = 0;
  int currentRotation = 0;

  while (currentRepetition < repeatCount) {
    currentRotation = 0;
    await Future.forEach<double>(angles, (rotateAngle) async {
      animateSimpleRotation(
        angle: rotateAngle,
        duration: rotationDuration?[currentRotation],
        curve: curves?[currentRotation] ?? Curves.decelerate,
      );
      await Future.delayed(
        pauseDuration?[currentRotation] ?? const Duration(seconds: 1),
      );
      currentRotation++;
    });
    currentRepetition++;
  }
  if (normalizeOnFinish) gameRef.camera.animateSimpleRotation(angle: 0.0);
  onFinish?.call();
}