fetchRouting function

Future<RoutingInfo?> fetchRouting(
  1. Client client,
  2. List<LatLng> lstLatLng
)

Implementation

Future<RoutingInfo?> fetchRouting(http.Client client,List<LatLng> lstLatLng) async {
  if(lstLatLng.isEmpty) {
    return null;
  }
  String params = "coordinates=";
  lstLatLng.asMap().forEach((index,item) => {
      params+=item.longitude.toString()+","+item.latitude.toString()+(index != (lstLatLng.length -1) ? ";" : "")

    });

  final response = await client
      .get(Uri.parse('https://mapi.darkvn.net/v2/routing/v2/directions/mobiledriving?'+params));
  print('Routing Coords:${Uri.parse('https://mapi.darkvn.net/v2/routing/v2/directions/mobiledriving?'+params)}');
  // Use the compute function to run parsePhotos in a separate isolate.
  return RoutingInfo.fromJson(jsonDecode(response.body));
}