hold method

Future hold(
  1. FutureOr fn(), [
  2. int ms = 400
])

Implementation

Future hold(FutureOr Function() fn, [int ms = 400]) {
  _timer?.cancel();
  c ??= Completer();
  _timer = Timer(
    Duration(milliseconds: ms),
    () async {
      final cr = c!;
      c = null;
      final r = await fn();
      cr.complete(r);
    },
  );
  return c!.future;
}