throttle function
Implementation
Function throttle(Function func, [delay = 1500, leading = true]) {
Timer? timer;
return ([Object? arg]) {
if (timer == null) {
timer = Timer(Duration(milliseconds: delay), () {
if (!leading) Function.apply(func, arg == null ? null : [arg]);
timer = null;
});
if (leading) Function.apply(func, arg == null ? null : [arg]);
}
};
}