Firebase 如何使用DocumentSnapshot而不是QuerySnapshot?

Firebase 如何使用DocumentSnapshot而不是QuerySnapshot?,firebase,flutter,dart,google-cloud-firestore,Firebase,Flutter,Dart,Google Cloud Firestore,我使用QuerySnapshot方法从firebase获取一些数据: getBookings(AsyncSnapshot<QuerySnapshot> snapshot) { return snapshot.data.docs .map((doc) => CalendarBookingBlock( bookingName: doc.data()['bookingName'], bookingTime: doc.data()['

我使用QuerySnapshot方法从firebase获取一些数据:

  getBookings(AsyncSnapshot<QuerySnapshot> snapshot) {
return snapshot.data.docs
    .map((doc) => CalendarBookingBlock(
          bookingName: doc.data()['bookingName'],
          bookingTime: doc.data()['bookingData'],
        ))
    .toList();
}
getBookings(异步快照快照){
返回snapshot.data.docs
.map((doc)=>CalendarBookingBlock(
bookingName:doc.data()['bookingName'],
bookingTime:doc.data()['bookingData'],
))
.toList();
}
但我必须使用DocumentSnapshot。当我尝试使用它时,没有为“DocumentSnapshot”类型定义
snapshot.data.docs
。我应该怎么做才能解决这个问题?

A表示一个文档。它不包含其他文档,例如。中有查询单个文档的示例。通常是这样的:

if (snapshot.exists) {
    Map<String, dynamic> data = snapshot.data();
    // document fields are in data
}
else {
    // decide what you want to do if the document doesn't exist
}
if(snapshot.exists){
Map data=snapshot.data();
//文档字段位于数据中
}
否则{
//如果文档不存在,请决定要执行的操作
}
A表示单个文档。它不包含其他文档,例如。中有查询单个文档的示例。通常是这样的:

if (snapshot.exists) {
    Map<String, dynamic> data = snapshot.data();
    // document fields are in data
}
else {
    // decide what you want to do if the document doesn't exist
}
if(snapshot.exists){
Map data=snapshot.data();
//文档字段位于数据中
}
否则{
//如果文档不存在,请决定要执行的操作
}