this is a piece of my code. i want to fecth all users except the current-user from the firestore collections. but i got this error(The argument type 'QueryDocumentSnapshot<Object?>' can't be assigned to the parameter type 'Map<String, dynamic>'). Here it's underline in red: querySnapshot.docs[i].data()
Future <List<kako.User>> fetchAllUsers(User currentUser) async{
List<kako.User> userList = List<kako.User>.generate(20, (index)=>kako.User());
QuerySnapshot querySnapshot =await fireStore.collection("users").get();
for (var i = 0; i < querySnapshot.docs.length ; i++) {
if(querySnapshot.docs[i].id != currentUser.uid){
userList.add(kako.User.fromMap(querySnapshot.docs[i].data()));
}
}
return userList;
}
Try:
userList.add(kako.User.fromMap(querySnapshot.docs[i].data() as Map<String, dynamic>))
Collected from the Internet
Please contact [email protected] to delete if infringement.
Comments