我试图在谷歌Map上做一个导航标记,对于用户位置,我使用geolocator pub dev的监听功能,但它返回为一个位置?因为它有空的可能性,它不能直接使用,有人能告诉我如何做吗?
Position? listenToLocation()
{
Position? userposition;
final LocationSettings _locationSettings = LocationSettings(accuracy: LocationAccuracy.high,distanceFilter: 100);
userStreamlocation = Geolocator.getPositionStream(locationSettings: _locationSettings).listen(
(userposition) {
print(userposition == null ? 'Unknown' : '${userposition.latitude.toString()}, ${userposition.longitude.toString()}');
setState(){
streamResult=userposition;
}
});
return userposition;
}
3条答案
按热度按时间pcww981p1#
使用onDragEnd功能拖动并释放标记,并确保在下面给出的代码中使“draggable”为true u...
最新列表数据标记=widget.apiDataArray.map((值){
}).到列表();
wgxvkvu92#
在发现标记未更新(因为它处于与主小部件不同的状态)后,我能够修复此问题,我通过使用状态构建器小部件修复了此问题,以下是代码片段
这样,谷歌Map就有了自己的状态,并且可以刷新
qeeaahzv3#
试试下面,