runDebounce method
void
runDebounce(
- dynamic identify,
- VoidCallback call, {
- Duration duration = const Duration(milliseconds: 400),
Uses to apply debounce.
Example:
runDebounce( 'increment', () => print(count.value), duration: Duration(seconds: 1), );
Implementation
@protected
void runDebounce(
dynamic identify,
VoidCallback call, {
Duration duration = const Duration(milliseconds: 400),
}) {
try {
if (_debounceMap == null) {
_debounceMap = {};
}
if (_debounceMap?.containsKey(identify) == true) {
if (_debounceMap![identify]?.delay != duration) {
_debounceMap![identify] = Debounce(duration);
}
_debounceMap![identify]?.call(call);
} else {
_debounceMap![identify] = Debounce(duration);
_debounceMap![identify]?.call(call);
}
} on Exception catch (e) {
print('[ERROR]runDebounce: $e');
}
}