throttle function

Function throttle(
  1. Function func,
  2. Duration delay
)

Implementation

Function throttle(Function func, Duration delay) {
  Timer? timer;

  return () {
    if (timer == null || !timer!.isActive) {
      timer = Timer(delay, () => func());
    }
  };
}