isQueryAllowed method
Check if a new query is allowed.
Implementation
bool isQueryAllowed() {
final now = DateTime.now();
final oneMinuteAgo = now.subtract(const Duration(minutes: 1));
// Remove old timestamps
_queryTimestamps.removeWhere(
(timestamp) => timestamp.isBefore(oneMinuteAgo),
);
if (_queryTimestamps.length >= maxQueriesPerMinute) {
if (SearchBarSecurityConfig.enableSecurityLogging) {
debugPrint('[SAC SearchBar Security] Rate limit exceeded');
}
return false;
}
_queryTimestamps.add(now);
return true;
}