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'));
Properties
Methods
-
call(
void action()) → void -
Executes the
actionimmediately 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