debounce function
When the given function is executed repeatedly, the function is called if it has not been called again within the specified timeout. This function is used when a small number of function calls are needed for repetitive input events.
Implementation
Function debounce(Function func, int timeout) {
Timer? timer;
return ([List<dynamic> args = const []]) {
timer?.cancel();
timer = Timer(Duration(milliseconds: timeout), () {
Function.apply(func, args);
});
};
}