1

I am developing an app in flutter using google maps. I have enabled google directions API to get the route between origin and destination. My app does not show any error but at the same time, it does not display the route. The google directions API shows an error in the google console. What could be the reason for this error? Here is the error

The function is:

getSomePoints() async{
  var permissions= await Permission.Permission.getPermissionsStatus([Permission.PermissionName.Location]);
  if(permissions[0].permissionStatus== Permission.PermissionStatus.notAgain){
    var askpermissions=
    await Permission.Permission.requestPermissions([Permission.PermissionName.Location]);
  }
  else{
  routeCoords = await googleMapPolyline.getCoordinatesWithLocation(
  origin: LatLng(12.900288, 77.648672),
  destination: LatLng(12.917166, 77.610),
  mode: RouteMode.driving);
}
}

Error is:

RangeError (index): Invalid value: Valid value range is empty: 0
E/flutter (24569): #0      NetworkUtil.getRouteBetweenCoordinates 
package:flutter_polyline_points/src/network_util.dart:29
E/flutter (24569): <asynchronous suspension>
E/flutter (24569): #1      PolylinePoints.getRouteBetweenCoordinates 
package:flutter_polyline_points/flutter_polyline_points.dart:22
E/flutter (24569): #2      _GMapState.initState.setPolylines 
package:sample_app/gmap.dart:136
E/flutter (24569): #3      _GMapState.initState 
Sadiya Ali
  • 11
  • 4
  • That is not the error. That is a picture of a metric. What is the actual error? – ecg8 Sep 06 '20 at 02:17
  • Thanks for the reply. I have updated the code and error. What could be the possible solution? – Sadiya Ali Sep 06 '20 at 06:12
  • 1
    Is your API key restricted? If so try unrestricting it. Does it work now? If it still doesn't, check that billing is enabled and that you are using your project's API key in your app. – evan Sep 07 '20 at 14:16

0 Answers0