call method

void call(
  1. Function func, {
  2. Duration? duration,
})

Implementation

void call(Function func, {Duration? duration}) {
  String symbol = '$runtimeType.call';
  bool isSyncCall = StackTrace.current.toString().replaceFirst(symbol, '_').contains(symbol);
  if (isSyncCall) {
    if (callers.contains(this)) {
      Journal.d('❌❗️ Do not call function ThrottleAny.call in the same stack with the same instance of ThrottleAny! ${callers.length}');
      func();
      return;
    }
  }
  try {
    callers.add(this);
    _call(func, duration: duration);
  } catch (e) {
    rethrow;
  } finally {
    callers.remove(this);
  }
}