class ThrottleUtil {
  static const Duration _KDelay = Duration(milliseconds: 1000);
  var enable = true;

  ///防止重复点击
  ///func 要执行的方法
  void Function()? throttle(
    Function? func, {
    Duration delay = _KDelay,
  }) {
    return () {
      if (enable) {
        func?.call();
        enable = false;
        Future.delayed(delay, () {
          enable = true;
        });
      }
    };
  }
}
