Skip to content

Instantly share code, notes, and snippets.

@Klerith
Last active February 22, 2025 03:09
Show Gist options
  • Select an option

  • Save Klerith/62b00635acec3614d2b35c066df724e6 to your computer and use it in GitHub Desktop.

Select an option

Save Klerith/62b00635acec3614d2b35c066df724e6 to your computer and use it in GitHub Desktop.
Flutter: Debouncer manual
import 'dart:async';
// Creditos
// https://stackoverflow.com/a/52922130/7834829
class Debouncer<T> {
Debouncer({
required this.duration,
this.onValue
});
final Duration duration;
void Function(T value)? onValue;
T? _value;
Timer? _timer;
T get value => _value!;
set value(T val) {
_value = val;
_timer?.cancel();
_timer = Timer(duration, () => onValue!(_value!));
}
}
@freedomCruz
Copy link
Copy Markdown

Super entretenidos tus cursos. Gracias Fernando!!!

@AngieMeliss
Copy link
Copy Markdown

Muchas gracias Fer, eres un teso, aprendo demasiado de vos <3

@AndresH11
Copy link
Copy Markdown

Muchas gracias

@BryanAlex
Copy link
Copy Markdown

Muchas gracias Fernando. No dejo de aprender con vos.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment