PIbd31_Teryokhin.A.S._PMU/lib/components/utils/debounce.dart
2024-10-29 16:33:19 +03:00

23 lines
400 B
Dart

import 'dart:async';
import 'dart:ui';
import 'package:flutter/cupertino.dart';
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);
}
}