OkHttp sendRequest Необработанное Исключение: Исключение: RangeError (индекс): Неверное значение: Диапазон допустимых значений пуст: 0 - PullRequest
0 голосов
/ 02 мая 2020

Я получаю эту ошибку, когда запрашиваю полилинии в картах Google (трепетание)

и код, в котором выдается ошибка, void setPolylines () asyn c {

List<PointLatLng> result = await polylinePoints.getRouteBetweenCoordinates(
    googleAPIKey,
    SOURCE_LOCATION.latitude,
    SOURCE_LOCATION.longitude,
    DEST_LOCATION.latitude,
    DEST_LOCATION.longitude);
if (result.isNotEmpty) {
  // loop through all PointLatLng points and convert them
  // to a list of LatLng, required by the Polyline
  result.forEach((PointLatLng point) {
    polylineCoordinates.add(LatLng(point.latitude, point.longitude));
  });
}

setState(() {
  // create a Polyline instance
  // with an id, an RGB color and the list of LatLng pairs
  Polyline polyline = Polyline(
      polylineId: PolylineId("poly"),
      color: Color.fromARGB(255, 40, 122, 198),
      points: polylineCoordinates);

  // add the constructed polyline as a set of points
  // to the polyline set, which will eventually
  // end up showing up on the map
  _polylines.add(polyline);
});

}

полный код, который я использовал от https://medium.com/flutter-community/drawing-route-lines-on-google-maps-between-two-locations-in-flutter-4d351733ccbe

...