尝试从我的文档中捕获特定字段。这是包装程序的代码,
class Wrapper extends StatelessWidget {
@override
Widget build(BuildContext context) {
final user = Provider.of<User>(context);
print(user);
// return either the Home or Authenticate widget
if (user == null) {
return Authenticate();
} else {
return FirmHomePage();
}
}
}
这是我们在控制台中用于打印的代码。
void idss() async {
FirebaseUser userid = await FirebaseAuth.instance.currentUser();
var document = await Firestore.instance.collection('Users').getDocuments();
for (var document in document.documents) {
messagetext = document.data['JobType'];
usettype = messagetext;
print(messagetext);
}
}
我们要检查我们的用户为其设置路径。
答案 0 :(得分:1)
FirebaseUser用户ID =等待FirebaseAuth.instance.currentUser();
final QuerySnapshot result = await Firestore.instance.collection('Users')
.where('uid', isEqualTo: currentUser.uid) .getDocuments();
final List < DocumentSnapshot > documents = result.documents;
if (documents.length == 1) {
//your code here
}else{
//your code here
}