update distance calculation to from current location

This commit is contained in:
Mohamed Nouffer
2023-06-19 15:29:25 +05:30
parent 3e06c4cd7f
commit bfb238323b

View File

@ -66,11 +66,12 @@ class _ListWidgetState extends State<ListWidget> {
Future<String> matrixDistance(int i) async { Future<String> matrixDistance(int i) async {
// Create two destinations directly from indexController.locations[0].collection // Create two destinations directly from indexController.locations[0].collection
Destination dest1 = createDestination(indexController.locations[0].collection[i]); Destination desCurr = Destination(lat: indexController.current_lat, lon: indexController.current_lon);
Destination dest2 = createDestination(indexController.locations[0].collection[i+1]); //Destination dest1 = createDestination(indexController.locations[0].collection[0]);
Destination dest2 = createDestination(indexController.locations[0].collection[i]);
// Get the distance between these two destinations // Get the distance between these two destinations
final res = await MatrixService.getDestinations([dest1, dest2]); final res = await MatrixService.getDestinations([desCurr, dest2]);
return res["routes"][0]["legs"][0]["distance"]["text"]; return res["routes"][0]["legs"][0]["distance"]["text"];
//print("matrix result is ${i} : ${res["routes"][0]["legs"][0]["distance"]["text"]} "); //print("matrix result is ${i} : ${res["routes"][0]["legs"][0]["distance"]["text"]} ");