run method

void run(
  1. void action(), {
  2. int cooldownMs = 1000,
})

Implementation

void run(void Function() action, {int cooldownMs = 1000}) {
  if (isBusy.value) return; // Ignore extra taps
  isBusy.value = true;

  // Call the original callback
  action();

  // Reset after cooldown
  Future.delayed(Duration(milliseconds: cooldownMs), () {
    if (isClosed) return;
    isBusy.value = false;
  });
}