getApiKey function

Future<String> getApiKey()

Retrieves the API key from the storage configuration. Throws an exception if the API key is not defined.

Implementation

Future<String> getApiKey() async {
  final config = await getStorageItem(key: 'sgm_config');
  final apiKey = config?['apiKey'];

  if (apiKey == null || apiKey == '') {
    throw Exception('Error: API Key is not defined.');
  }

  return apiKey;
}