Warning: file_get_contents(/data/phpspider/zhask/data//catemap/4/fsharp/3.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181
Flutter 如何获取存储在数据库中的坐标纬度和长度,以等待Geolocator()。颤振之间的距离_Flutter_Https - Fatal编程技术网

Flutter 如何获取存储在数据库中的坐标纬度和长度,以等待Geolocator()。颤振之间的距离

Flutter 如何获取存储在数据库中的坐标纬度和长度,以等待Geolocator()。颤振之间的距离,flutter,https,Flutter,Https,我正在尝试获取两个位置之间的距离。其中一个位置是用户当前位置(currentLocation.latitude、currentLocation.longitude),另一个位置是我数据库中存储的位置(lat和lng)。我能够成功获取用户当前位置,也能够获取存储在数据库中的纬度和经度,但使用下面的代码,它只返回经度和经度列表中的一个 String lat = ""; String lng = ""; Double distanceInKilometers = ""; Future getDist

我正在尝试获取两个位置之间的距离。其中一个位置是用户当前位置(currentLocation.latitude、currentLocation.longitude),另一个位置是我数据库中存储的位置(lat和lng)。我能够成功获取用户当前位置,也能够获取存储在数据库中的纬度和经度,但使用下面的代码,它只返回经度和经度列表中的一个

String lat = "";
String lng = "";
Double distanceInKilometers = "";

Future getDistance() async {

    distanceInMeters = await Geolocator().distanceBetween(
        currentLocation.latitude, currentLocation.longitude, double.parse(lat), double.parse(lng));

    distanceInKilometers = distanceInMeters.toInt() / 1000;

    }


ListView.separated( itemCount: content.length,
                     itemBuilder: (context, position) {
                                      lat = content[position].lat;
                                      lng = content[position].lng;

                      return Container(
child: Column(
children: <Widget>[
new Text(distanceInKilometers.toString())
],
),
))


字符串lat=”“;
字符串lng=“”;
双距离里程计=“”;
Future getDistance()异步{
distanceInMeters=等待地理定位器()(
currentLocation.latitude、currentLocation.longitude、double.parse(lat)、double.parse(lng));
distanceInKilometers=distanceInMeters.toInt()/1000;
}
ListView.separated(itemCount:content.length,
itemBuilder:(上下文、位置){
lat=内容[位置]。lat;
lng=含量[位置].lng;
返回容器(
子:列(
儿童:[
新文本(distanceInKilometers.toString())
],
),
))

为了可读性,您应该尝试将代码限制为您使用的方法,但失败了。@i6x86我刚刚减少了代码。您有解决方案吗?我正在从数据库中获取纬度和经度,并希望在getDistance()中使用它要分别替换25.1972和55.2744,您在哪里填充当前位置?@Muhammed Noman我实际上找到了一种方法来处理此链接,但我面临的问题与此人当时面临的问题相同。如果您可以在链接上帮助解决此问题,我很好。那么,您现在遇到了什么错误?为什么不能使用这些值?您应该尝试限制您的cod由于可读性的原因,我选择了您使用的方法,但失败了。@i6x86我刚刚减少了代码。您对此有什么解决方案吗?基本上,我正在从数据库中获取纬度和经度,并希望在getDistance()中使用它要分别替换25.1972和55.2744,您在哪里填充当前位置?@Muhammed Noman我实际上找到了一种方法来处理此链接,但我面临的问题与此人当时面临的问题相同。如果您可以在链接上帮助解决此问题,我很好。那么,您现在遇到了什么错误?为什么不能使用这些值?