throttle static method
ThrottledCallback
throttle(
- void func(),
- Duration interval, {
- bool leading = true,
- bool trailing = false,
- ThrottlerErrorHandler? onError,
Creates a throttled callback that invokes func at most once per interval.
The returned object is callable like a function and supports cancel/dispose.
Implementation
static ThrottledCallback throttle(
void Function() func,
Duration interval, {
bool leading = true,
bool trailing = false,
ThrottlerErrorHandler? onError,
}) {
final throttler = Throttler(
interval: interval,
leading: leading,
trailing: trailing,
onError: onError,
);
return ThrottledCallback(throttler, func);
}