getAltTranslation method
Implementation
Future<AlternativeTranslation> getAltTranslation(
String sourceText, {
String from = autoLanguage,
required String to,
}) async {
final HttpResponseData httpResponseData =
await _getData(sourceText, from, to: to, dataType: 'at');
final jsonData = httpResponseData.jsonData;
final List<String> translations = [];
try {
final indexedData =
jsonData[_map[RequestType.alternativeTranslation]][0][2];
for (final i in indexedData) {
final translation = i[0] as String;
if (!translations.contains(translation)) translations.add(translation);
}
} catch (e) {
_throwBadDataException(
RequestType.alternativeTranslation,
httpResponseData,
innerException: e,
);
}
return AlternativeTranslation(
translations,
source: sourceText,
sourceLanguage: _languageList[from],
targetLanguage: _languageList[to],
);
}