Throttle class

A utility class for throttling function calls.

Throttling ensures that a function is executed at most once within a specified duration, regardless of how many times it is invoked.

Example:

final throttled = Throttle(Duration(milliseconds: 500));
throttled(() => print('Called at most once every 500ms'));

Constructors

Throttle(Duration delay)
Creates a Throttle instance with the specified delay.

Properties

delay Duration
The minimum duration between consecutive function executions.
final
hashCode int
The hash code for this object.
no setterinherited
runtimeType Type
A representation of the runtime type of the object.
no setterinherited

Methods

call(void action()) → void
Executes the action immediately if not throttled, otherwise ignores the call.
cancel() → void
Cancels any pending throttle and resets the state.
copyWith({Duration? delay}) Throttle
Creates a copy of this Throttle with the given fields replaced.
dispose() → void
Disposes of the throttle instance and cancels any pending timers.
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