Debouncer class final
A practical Debouncer for optimizing performance by controlling the frequency of function calls in response to rapid events.
Constructors
Properties
- delay → Duration
-
The delay before calling the
_onWaitedfunction.final - hashCode → int
-
The hash code for this object.
no setterinherited
- isPending → bool
-
Whether a debounce window is currently open — i.e. a call has been
made and the delay has not yet elapsed (and the debouncer has not
been cancelled or finalized).
no setter
- onCall → _VoidCallback?
-
no setter
- onStart → _VoidCallback?
-
no setter
- onWaited → _VoidCallback?
-
no setter
- runtimeType → Type
-
A representation of the runtime type of the object.
no setterinherited
Methods
-
call(
{FutureOr< void> onStart()?, FutureOr<void> onWaited()?, FutureOr<void> onCall()?}) → FutureOr<void> -
Calls the
onCallfunction and then waits for delay before calling theonWaitedfunction. -
cancel(
) → bool -
Cancels any pending wait. Returns
trueif a wait was actually cancelled,falseif there was nothing pending. -
dispose(
) → void - Cancels any pending wait and resets the debouncer. The pending onWaited callbacks are dropped (use finalize to flush them instead). The instance can still be reused after dispose.
-
finalize(
{FutureOr< void> onWaited()?}) → FutureOr<void> -
Finalizes the debouncer: cancels the pending timer (if any) and
immediately runs the
onWaitedcallbacks. Resets the started state so that the next call will fire onStart again. -
noSuchMethod(
Invocation invocation) → dynamic -
Invoked when a nonexistent method or property is accessed.
inherited
-
toString(
) → String -
A string representation of this object.
inherited
Operators
-
operator ==(
Object other) → bool -
The equality operator.
inherited