PIbd-31_MasenkinMS_PMU/lib/components/utils/debounce.dart
2024-09-30 22:15:55 +04:00

21 lines
358 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);
}
}