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