flutter / firestore获取搜索字段,并通过documentId检查其他字段

时间:2020-02-25 15:11:24

标签: flutter google-cloud-firestore field snapshot

我正在尝试获取消防站中文档字段中的搜索值(用户ID),我想检查该方法但失败的文档的其他字段(状态)

handlesubmit(BuildContext context)async{

   final QuerySnapshot searcheduserid=
                   await Firestore.instance.collection('users')
                .where('userid',isEqualTo: userid).limit(1).getDocuments();

   final userdocid=searcheduserid.documents.map((doc)=>doc.documentID);

   final DocumentSnapshot getuserdoc= await Firestore.instance.collection('users')
                          .document(userdocid).get();

   final userstatus = getuserdoc.data['status'];//  I GET AN ERROR HERE ERROR SAYS

   // METHOD [](status) was called on null

 if(userstatus==null){
 return showdialog( context,'the entered user id status does not exist');
}

}

谢谢你<3

0 个答案:

没有答案