call method Null safety

Object? call(
  1. [List<Object>? args,
  2. Map<Symbol, Object>? namedArgs]

Dynamically call this Debounce with the specified arguments.

Acts the same as calling _func with positional arguments corresponding to the elements of args and named arguments corresponding to the elements of namedArgs.

This includes giving the same errors if _func isn't callable or if it expects different parameters.


List<Movie> fetchMovies(
   String movieName, {
   bool adult = false,
 }) async {
   final data = api.getData(query);

final debouncedFetchMovies = Debounce(
  const Duration(milliseconds: 350),

debouncedFetchMovies(['tenet'], {#adult: true});

gives exactly the same result as

fetchMovies('tenet', adult: true).


Object? call([List<Object>? args, Map<Symbol, Object>? namedArgs]) {
  final time =;
  final isInvoking = _shouldInvoke(time);

  _lastArgs = args;
  _lastNamedArgs = namedArgs;
  _lastCallTime = time;

  if (isInvoking) {
    if (_timer == null) {
      return _leadingEdge(_lastCallTime!);
    if (_maxing) {
      // Handle invocations in a tight loop.
      _timer = _startTimer(_timerExpired, _wait);
      return _invokeFunc(_lastCallTime!);
  _timer ??= _startTimer(_timerExpired, _wait);
  return _result;