editApiKey static method

Future<void> editApiKey(
  1. String name,
  2. String newKey,
  3. String serviceType
)

Edit a single API key in the session

Implementation

static Future<void> editApiKey(
    String name, String newKey, String serviceType) async {
  List<ApiKeyModel> apiKeys = await getApiKeys();
  apiKeys = apiKeys
      .map((apiKey) =>
          apiKey.name == name && apiKey.serviceType == serviceType
              ? ApiKeyModel(
                  name: apiKey.name,
                  key: newKey,
                  serviceType: serviceType,
                  isDefault: apiKey.isDefault)
              : apiKey)
      .toList();
  await saveApiKeys(apiKeys);
}