Throttler class
A utility to enforce a maximum execution frequency for a function.
Useful for scroll handlers, button tap protection, and rate-limited APIs.
final Throttler throttler = Throttler(duration: const Duration(milliseconds: 500));
void onButtonPressed() {
throttler.run(() => submitPayment());
}
Constructors
Properties
Methods
-
dispose(
) → void - Disposes the throttler.
-
noSuchMethod(
Invocation invocation) → dynamic -
Invoked when a nonexistent method or property is accessed.
inherited
-
reset(
) → void - Resets the throttle timer.
-
run(
void action(), {bool trailing = false}) → void -
Runs
actionif duration has elapsed since the last execution. -
toString(
) → String -
A string representation of this object.
inherited
Operators
-
operator ==(
Object other) → bool -
The equality operator.
inherited