addApiKey static method
- ApiKeyModel newApiKey
Add a single API key to the session
Implementation
static Future<void> addApiKey(ApiKeyModel newApiKey) async {
List<ApiKeyModel> apiKeys = await getApiKeys();
if (apiKeys.any((apiKey) =>
apiKey.name == newApiKey.name &&
apiKey.serviceType == newApiKey.serviceType)) {
apiKeys = apiKeys
.map((apiKey) => apiKey.name == newApiKey.name &&
apiKey.serviceType == newApiKey.serviceType
? newApiKey
: apiKey)
.toList();
} else {
apiKeys.add(newApiKey);
}
await saveApiKeys(apiKeys);
}