spellingSuggestions method

Future<List> spellingSuggestions(
  1. String word
)

spellingSuggestions is a class for making HTTP requests to the ZEMBEREK API using the word parameter and print word in the console.

Implementation

Future<List<dynamic>> spellingSuggestions(String word) async {
  try {
    var url = (Uri.parse('$ipAdresi:$port/spelling_suggestions'));
    var res = await http.post(url, body: {'word': word});
    var body = res.body;
    var decoded = jsonDecode(body);
    var cevap = decoded["suggestions"];
    return cevap;
  } catch (e) {
    var hata = e.toString();
    if (hata.contains('NoSuchMethodError')) {
      print("Probably System Error. Open an issue on GitHub.");
      return [];
    } else {
      var sozlukanlam = e.toString();
      print(sozlukanlam);
      return [];
    }
  }
}