throttle method Null safety

dynamic throttle(
  1. Function func
)

limits the maximum number of times a given event handler can be called over time

Implementation

dynamic throttle(Function func) {
  if (!_isReady) return null;
  _stateSC.sink.add(false);
  _isReady = false;
  _waiter.then((_) {
    _isReady = true;
    if (!_stateSC.isClosed) {
      _stateSC.sink.add(true);
    }
  });
  return Function.apply(func, []);
}