debounce function

VoidCallback debounce(
  1. FutureOr<void> f(), [
  2. Duration duration = const Duration(milliseconds: 10)
])

Creates a closure that delays the execution by duration the invocation of f If the the closure was invoked withing the duration again, it would reset the elapsed time

Implementation

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