Am trying to get the distance two coordinate in a future build which was successful but am looking for how to get the value returned "kmDis" in Text() widget in body: of my code. Check below for my full code.
Future<String> getDistance(String lat, String lng) async {
final distanceInMeters = await Geolocator().distanceBetween(
currentLocation.latitude,
currentLocation.longitude,
double.parse(lat),
double.parse(lng));
double distancekm = distanceInMeters / 1000;
String kmDis = distancekm.toStringAsFixed(1);
//int finalkm = distancekm.round();
return kmDis;
}
@override
Widget build(BuildContext context) {
return Scaffold(
body:Text("i want to return my kmDis value as string here.")
)
}