doubleClickConfirmation static method

Future<bool> doubleClickConfirmation({
  1. int? interval = 1000,
  2. VoidCallback? first,
  3. VoidCallback? second,
})

Implementation

static Future<bool> doubleClickConfirmation({int? interval = 1000, VoidCallback? first, VoidCallback? second}) {
  int now = DateTime.now().millisecondsSinceEpoch;
  if (now - _doubleClickConfirmation > (interval ?? 1000)) {
    _doubleClickConfirmation = DateTime.now().millisecondsSinceEpoch;
    first?.call();
    return Future.value(false);
  } else {
    second?.call();
    return Future.value(true);
  }
}