rotate method

void rotate(
  1. double rotateTo, [
  2. bool animate = false,
  3. Function? onAnimateEnd
])

Implementation

void rotate(
  double rotateTo, [
  bool animate = false,
  Function? onAnimateEnd,
]) {
  log('MapStates rotate $rotateTo');

  if (animate) {
    _rotateAnim = CurvedAnimationController(
      begin: normalizeDeg(_rotation),
      end: normalizeDeg(rotateTo),
      vsync: _vsync,
      duration: const Duration(milliseconds: 250),
      curve: Curves.ease,
    );

    _rotateAnim?.addListener(() {
      rotation = _rotateAnim!.value;
    });

    _rotateAnim?.addStatusListener((status) {
      if (status == AnimationStatus.completed) {
        onAnimateEnd?.call();
        _rotateAnim?.dispose();
      }
    });

    _rotateAnim
      ?..reset()
      ..start();
  } else {
    rotation = rotateTo;
  }
}