useDebounce function

void useDebounce(
  1. VoidCallback fn,
  2. Duration delay, [
  3. List<Object?>? keys
])

Flutter hook that delays invoking a function until after wait milliseconds have elapsed since the last time the debounced function was invoked. The third argument is the array of values that the debounce depends on, in the same manner as useEffect. The debounce timeout will start when one of the values changes.

Implementation

void useDebounce(VoidCallback fn, Duration delay, [List<Object?>? keys]) {
  final timeout = useTimeoutFn(fn, delay);
  useEffect(() => timeout.reset, keys);
}