getLanguage function

Future<String> getLanguage()

Retrieves the language configuration from the storage.

Returns the language code if it is defined in the configuration. Throws an exception if the language is not defined.

Throws:

  • Exception: If the language is not defined in the configuration.

Returns:

  • String: The language code. ยง Example usage:
final language = await getLanguageConfiguration();
print(language); // en_US

Implementation

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

  if (language == null) {
    throw Exception('Error: Language is not defined.');
  }

  return language;
}