1

Currently I use a Widget which converts coordinates between different formats. The methods are all running synchronously. Now I want to implement the What3Word-Format which uses an async API.

My problem is, that the program does not stop and wait at the await API-Call.

Searching all the articles in the net does not provide an answer/solution.

The code is

Future<What3Words> _lToW(LatLng coord, String language) async {
  String APIKey = Prefs.getString('coord_default_w3w_apikey');

  var api = What3WordsV3(APIKey);

  var words = await api.convertTo3wa(Coordinates(coord.latitude, coord.longitude))
                       .language(language)
                       .execute();
  
  if (words.isSuccessful()) {
    var w3w = words.data().words.split('.');
    return What3Words(w3w[0], w3w[1], w3w[2], language);
  } else {
    return What3Words('', '', '', language);
  }
}

What3Words LatLonToWhat3Words(LatLng coord, String language) {
  _lToW(coord, language).then((value) {
    return value;
  });
}
TMZ
  • 11
  • 2

0 Answers0