debounce static method
Creates a debounced callback that delays the execution of func until
duration has passed since the last time it was invoked.
The returned object is callable and exposes cancel and flush methods.
Implementation
static DebouncedCallback debounce(
FutureOr<void> Function() func,
Duration duration, {
Duration? maxWait,
bool immediate = false,
String? debugLabel,
}) {
final debouncer = Debouncer(
delay: duration,
maxWait: maxWait,
immediate: immediate,
debugLabel: debugLabel,
);
return DebouncedCallback(debouncer, func);
}