Function debounce(Function func, Duration delay) { Timer? timer; return () { timer?.cancel(); timer = Timer(delay, () => func()); }; }