getExamples method

Future<Example> getExamples(
  1. String sourceText, {
  2. String from = autoLanguage,
})

Implementation

Future<Example> getExamples(
  String sourceText, {
  String from = autoLanguage,
}) async {
  final HttpResponseData httpResponseData =
      await _getData(sourceText, from, dataType: 'ex');

  final jsonData = httpResponseData.jsonData;
  final List<String> list = [];
  try {
    final indexedData = jsonData[_map[RequestType.example]];
    for (final i in indexedData[0]) {
      final String string = i[0] as String;
      list.add(string);
    }
  } catch (e) {
    _throwBadDataException(
      RequestType.example,
      httpResponseData,
      innerException: e,
    );
  }
  return Example(
    list,
    source: sourceText,
    sourceLanguage: _languageList[from],
  );
}