debounce method

void debounce(
  1. Duration duration,
  2. void callback()
)

Implementation

void debounce(Duration duration, void Function() callback) {
  timer?.cancel();
  timer = Timer(duration, () {
    timer?.cancel();
    callback();
  });
}