PMU_Petrushin_PIbd-32/lib/components/util/Debounce.dart
2024-10-18 23:47:45 +04:00

20 lines
368 B
Dart

import 'dart:async';
import 'dart:ui';
class Debounce {
factory Debounce() => _instance;
Debounce._();
static final Debounce _instance = Debounce._();
static Timer? _timer;
static void run (
VoidCallback action, {
Duration delay = const Duration(milliseconds: 500),
}) {
_timer?.cancel();
_timer = Timer(delay, action);
}
}