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