animateToggle method

void animateToggle()

Flip the card If awaited, returns after animation completes.

Implementation

void animateToggle() {
  if (!mounted) return;
  widget.onFlip?.call();
  controller.duration = widget.duration;
  final animation = isFront ? controller.forward() : controller.reverse();
  animation.whenComplete(() {
    setState(() => isFront = !isFront);
    widget.onFlipDone?.call(isFront);
  });
}