SlidingWindowRateLimiter constructor

SlidingWindowRateLimiter({
  1. required int limit,
  2. required Duration window,
  3. DateTime now()?,
})

Creates a limiter permitting limit (≥ 1) events per window (> 0). now supplies the current time (defaults to DateTime.now); tests pass a virtual clock to advance time deterministically. Audited: 2026-06-12 11:26 EDT

Implementation

SlidingWindowRateLimiter({
  required this.limit,
  required this.window,
  // ignore: saropa_lints/prefer_correct_callback_field_name -- injected clock source, not an event callback
  DateTime Function()? now,
}) : _now = _validatedNow(limit, window, now);