debounce static method
Debounces the specified callback until the specified duration
has elapsed.
If a debounced call is made before the duration has elapsed, the timer
is reset and the callback is not executed until the timer has elapsed
again.
Implementation
static void debounce(void Function() callback, {Duration duration = const Duration(milliseconds: 500)}) {
_timer?.cancel();
_timer = Timer(duration, callback);
}