Debouncer class

A utility to delay function execution until a pause in invocation occurs.

Useful for search inputs, auto-saving forms, and resize events.

final Debouncer debouncer = Debouncer(duration: const Duration(milliseconds: 300));

void onSearchChanged(String query) {
  debouncer.run(() => fetchSearchResults(query));
}

Constructors

Debouncer({Duration duration = const Duration(milliseconds: 300)})
Creates a debouncer that waits for duration before executing.

Properties

duration → Duration
The delay duration.
final
hashCode → int
The hash code for this object.
no setterinherited
isPending → bool
Whether an execution is currently scheduled.
no setter
runtimeType → Type
A representation of the runtime type of the object.
no setterinherited

Methods

cancel() → void
Cancels the pending execution if any.
dispose() → void
Disposes the debouncer.
noSuchMethod(Invocation invocation) → dynamic
Invoked when a nonexistent method or property is accessed.
inherited
run(void action()) → void
Runs action after duration, canceling any previously scheduled call.
toString() → String
A string representation of this object.
inherited

Operators

operator ==(Object other) → bool
The equality operator.
inherited