inputThrottle method

void Function(String? text) inputThrottle({
  1. int milliseconds = 500,
})

Implementation

void Function(String? text) inputThrottle({int milliseconds = 500}) {
  var isAllowed = true;
  Timer? throttleTimer;
  return (text) {
    if (!isAllowed) return;
    isAllowed = false;
    this(text);
    throttleTimer?.cancel();
    throttleTimer = Timer(Duration(milliseconds: milliseconds), () {
      isAllowed = true;
    });
  };
}