hint method

Future<void> hint({
  1. Duration? duration,
  2. Duration? total,
})

Triggers a flip animation that reverses after the duration and will run for total If awaited, returns after animation completes.

Implementation

Future<void> hint({Duration? duration, Duration? total}) async {
  assert(controller is AnimationController);
  if (!(controller is AnimationController)) return;

  if (controller!.isAnimating || controller!.value != 0) return;

  final durationTotal = total ?? controller!.duration;

  final completer = Completer();

  Duration? original = controller!.duration;
  controller!.duration = durationTotal;
  controller!.forward();

  final durationFlipBack = duration ?? const Duration(milliseconds: 150);

  Timer(durationFlipBack, () {
    controller!.reverse().whenComplete(() {
      completer.complete();
    });
    controller!.duration = original;
  });

  await completer.future;
}