【发布时间】:2022-01-10 15:50:43
【问题描述】:
所以我想在 Flutter 中对我的应用实施基于角色的身份验证。只有具有权限的用户才能访问此站点。我得到了错误:
The getter 'documents' isn't defined for the type 'QuerySnapshot<Map<String, dynamic>>'.
Try importing the library that defines 'documents', correcting the name to the name of an existing getter, or defining a getter or field named 'documents'.
有人可以帮我吗?
代码:
class AutoLoginHandler extends StatelessWidget {
@override
authorizeAccess(BuildContext context) {
FirebaseAuth.instance.currentUser!().then((user) {
FirebaseFirestore.instance
.collection('/users')
.where('uid', isEqualTo: user.uid)
.get()
.then((docs) {
if (docs.documents[0].data.exists) {
if (docs.documents[0].data['role'] == 'admin') {
Navigator.of(context).push(new MaterialPageRoute(
builder: (BuildContext context) => new LehrerMainPage()));
}
}
});
});
}
}
【问题讨论】:
标签: android firebase flutter google-cloud-firestore