allowRequest method
Checks if a request is allowed based on rate limit
Implementation
bool allowRequest() {
final now = DateTime.now();
// Remove timestamps outside the current window
_requestTimestamps.removeWhere(
(timestamp) => now.difference(timestamp) > _windowDuration,
);
// Check if we're under the limit
if (_requestTimestamps.length < maxRequestsPerMinute) {
_requestTimestamps.add(now);
return true;
}
return false;
}