debounce static method

void debounce(
  1. Function func, [
  2. int delay = 500
])

防抖 (传入所要防抖的方法/回调与延迟时间)

Implementation

static void debounce(Function func, [int delay = 500]) {
  if (_debounceTimer != null) {
    _debounceTimer?.cancel();
  }
  _debounceTimer = Timer(Duration(milliseconds: delay), () {
    func.call();
    _debounceTimer = null;
  });
}