Throttler class

A lightweight throttler for rate-limiting actions over time.

Constructors

Throttler({required Duration interval, bool leading = true, bool trailing = false, ThrottlerErrorHandler? onError, Timer timerFactory(Duration duration, void callback())?})
Creates a Throttler that enforces a minimum delay between executions.

Properties

hashCode int
The hash code for this object.
no setterinherited
interval Duration
Minimum delay between executions.
final
isDisposed bool
Returns true if the throttler has been disposed.
no setter
isThrottled bool
Returns true if throttling is currently active.
no setter
leading bool
Whether to execute immediately on the first call in a burst.
final
runtimeType Type
A representation of the runtime type of the object.
no setterinherited
trailing bool
Whether to execute once at the end of a throttling window.
final

Methods

cancel() → void
Cancels any pending action and clears the current throttle window.
dispose() → void
Disposes the throttler and releases timers.
noSuchMethod(Invocation invocation) → dynamic
Invoked when a nonexistent method or property is accessed.
inherited
run(ThrottlerAction action) → void
Runs action under the current throttling rules.
toString() String
A string representation of this object.
inherited

Operators

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