throttle static method

dynamic throttle(
  1. Function func,
  2. int milliseconds
)

Implementation

static throttle(Function func, int milliseconds) {
  bool enable = true;
  return (val) {
    if (enable == true) {
      enable = false;
      Future.delayed(Duration(milliseconds: milliseconds), () {
        enable = true;
        func(val);
      });
    }
  };
}