【发布时间】:2020-12-23 17:16:39
【问题描述】:
您好,我想问一下如何从 Firestore 中检索数据并将其发送给替身。
这是我从 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() 中。
**如果您有什么想问的,请随时这样做,因为我不知道如何表达我的问题。非常感谢您。
【问题讨论】:
标签: flutter google-cloud-firestore