debounceInput static method

dynamic debounceInput(
  1. dynamic func(
    1. dynamic
    ), [
  2. int delay = 500
])

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

Implementation

static debounceInput(Function(dynamic) func, [int delay = 500]) {
  Timer? timer;
  return (dynamic value) {
    if (timer != null) {
      timer?.cancel();
    }
    timer = Timer(Duration(milliseconds: delay), () {
      func.call(value);
      timer = null;
    });
  };
}