validateApiKey method
Checks if an API key is valid and not expired.
-
Parameters:
- key: The API key to be validated.
-
Returns:
true
if the API key is valid,false
otherwise.
Implementation
bool validateApiKey(String key) {
return _apiKeys.any((apiKey) =>
apiKey.key == key &&
(apiKey.expiresAt == null ||
apiKey.expiresAt!.isAfter(DateTime.now())));
}