我正在开发最近的Food Dish应用程序位置。我设法使用此插件great_circle_distance,根据最接近用户的位置显示它
我想知道如何设置……
如果我理解你的问题是正确的
_foodByCategories.where((a) { var distance = new GreatCircleDistance.fromDegrees(latitude1: double.parse(widget.lat), longitude1: double.parse(widget.lng), latitude2: double.parse(a.lat), longitude2: double.parse(a.lng)); var totaldistance = distance.haversineDistance().toStringAsFixed(2); double distanceDouble1 = double.parse(totaldistance); return distance <= 30000; // or something like that }).sort ... // and your sorting code
我在你正在使用的包中看不到任何方法。您可以建议开发人员添加此功能吗?
或者,你得到了 total distance 在你的代码中,你可以做一个简单的 if statement 检查总距离是否大于设定的最大半径。
total distance
if statement