fetchSupportedLanguages method

Future<List<ChatTranslateLanguage>> fetchSupportedLanguages()

~english Gets all languages supported by the translation service.

Return The supported languages.

Throws A description of the exception. See ChatError. ~end

~chinese 查询翻译服务支持的语言。

Return 翻译服务支持的语言列表。

Throws 如果有异常会在此抛出,包括错误码和错误信息,详见 ChatError。 ~end

Implementation

Future<List<ChatTranslateLanguage>> fetchSupportedLanguages() async {
  Map result =
      await ChatChannel.invokeMethod(ChatMethodKeys.fetchSupportLanguages);
  try {
    ChatError.hasErrorFromResult(result);
    List<ChatTranslateLanguage> list = [];
    result[ChatMethodKeys.fetchSupportLanguages]?.forEach((element) {
      list.add(ChatTranslateLanguage.fromJson(element));
    });
    return list;
  } on ChatError catch (e) {
    throw e;
  }
}