嗨,我想问一下如何从Firestore检索数据并将其发送给Double。
这是我从Firestore检索数据的代码。
Firestore.instance
.collection('locations')
.snapshots()
.listen((driverLocation){
driverLocation.documents.forEach((dLocation){
dLocation.data['latitude'] = latitude;
dLocation.data['longitude'] = longitude;
print(latitude);
});
});
我将其存储在中dLocation
,当我print(dLocation.data)
在Firestore中显示纬度和经度时。但是当我将其传递给时double latitude
,double longitude
它返回null。
busStop.add(
Marker(
markerId: MarkerId('driverLocation')
,
draggable: false,
icon: BitmapDescriptor.defaultMarker,
onTap: () {
},
position: LatLng(latitude, longitude),
));
然后我想传递是在数据double latitude
和double longitude
进入标志,使得该标记将相应地移动到所述的FireStore纬度和经度。
这里发生的一切都在一个initState()
。
您已撤销分配
Firestore.instance
.collection('locations')
.snapshots()
.listen((driverLocation){
driverLocation.documents.forEach((dLocation){
latitude = dLocation.data['latitude'] ;
longitude = dLocation.data['longitude'] ;
print(latitude);
});
});
本文收集自互联网,转载请注明来源。
如有侵权,请联系[email protected] 删除。
我来说两句