initRotationAnimation method

void initRotationAnimation(
  1. RotationAnimationConfig config
)

initialize the rotation animation of current slice

Implementation

void initRotationAnimation(RotationAnimationConfig config) {
  if (!config.enabled) {
    rotationAnimation = ConstantTween<double>(0).animate(widget.controller);
    return;
  }

  List<TweenSequenceItem<double>> sequenceItemList = [];
  if (config.animationStartDelay > 0) {
    sequenceItemList.add(
      TweenSequenceItem(
          tween: ConstantTween(
            - widget.fanSlice.angleStart - 0.5 * widget.fanSlice.swipe,
          ),
          weight: config.animationStartDelay
      ),
    );
  }

  sequenceItemList.add(
    TweenSequenceItem(
        tween: Tween(
            begin: - widget.fanSlice.angleStart - 0.5 * widget.fanSlice.swipe,
            end: 0
        ),
        weight: 1 - config.animationFinishDelay - config.animationStartDelay
    ),
  );

  if (config.animationFinishDelay > 0) {
    sequenceItemList.add(
        TweenSequenceItem(
          tween: ConstantTween(0),
          weight: config.animationFinishDelay,
        )
    );
  }

  rotationAnimation = TweenSequence<double>(sequenceItemList).animate(
      CurvedAnimation(
        parent: widget.controller,
        curve: config.curve,
      )
  );
}