This commit is contained in:
problematicconsumer
2023-07-06 17:18:41 +03:30
commit b617c95f62
352 changed files with 21017 additions and 0 deletions

View File

@@ -0,0 +1,25 @@
import 'dart:async';
import 'package:flutter/foundation.dart';
class CallbackDebouncer {
CallbackDebouncer(this._delay);
final Duration _delay;
Timer? _timer;
/// Calls the given [callback] after the given duration has passed.
void call(VoidCallback callback) {
if (_delay == Duration.zero) {
callback();
} else {
_timer?.cancel();
_timer = Timer(_delay, callback);
}
}
/// Stops any running timers and disposes this instance.
void dispose() {
_timer?.cancel();
}
}