debounce function

VoidCallback debounce(
  1. FutureOr<void> f(), [
  2. Duration duration = kDefaultDebounce
])

Returns a closure that debounces calls to f by duration. Re‑invocation resets the timer. Useful for text search, resize, etc.

Implementation

VoidCallback debounce(
  FutureOr<void> Function() f, [
  Duration duration = kDefaultDebounce,
]) {
  final debouncer = Debouncer(duration: duration);
  return () => debouncer.run(f);
}