throttle method

void throttle(
  1. VoidCallback callback,
  2. Duration duration
)

Implementation

void throttle(VoidCallback callback, Duration duration) {
  if (!_throttled) {
    callback();
    _throttled = true;
    _throttleTimer?.cancel();
    _throttleTimer = Timer(duration, () {
      _throttled = false;
    });
  }
}