throttle function

void throttle(
  1. String id,
  2. VoidCallback runner, {
  3. bool leaky = false,
  4. Duration cooldown = const Duration(milliseconds: 250),
})

Implementation

void throttle(String id, VoidCallback runner,
    {bool leaky = false,
    Duration cooldown = const Duration(milliseconds: 250)}) {
  _throttleFunctions.putIfAbsent(
      id,
      () => leaky
          ? _LeakingThrottleFunction(cooldown, runner)
          : ThrottleFunction(cooldown, runner));
  _throttleFunctions[id]!.runner = runner;
  _throttleFunctions[id]!();
}