I have 2 kinds of users "d" and "p".
For them, there is a special collection - roles, which stores the user's uid and his role.
I'm trying to display a role and, based on the role, display the corresponding categories.
However, I am getting the following error.
The argument type 'Future<QuerySnapshot<Object?>>? Function(QuerySnapshot<Map<String, dynamic>>)' can't be assigned to the parameter type 'FutureOr<QuerySnapshot<Object?>> Function(QuerySnapshot<Map<String, dynamic>>)' because 'Future<QuerySnapshot<Object?>>?' is nullable and 'Future<QuerySnapshot<Object?>>' isn't.
What alternatives do I have to implement the same? The action takes place in a function that is then called and processed in the FutureBuilder.
getCategoryData(String _collection, {bool forMap = false}) {
FirebaseFirestore.instance.collection('roles').where('uid', isEqualTo: FirebaseAuth.instance.currentUser!.uid).get().then((value){
for (var element in value.docs) {
if(forMap == false && element.data()['role'] == 'd'){
Future<QuerySnapshot> _snapshot = FirebaseFirestore.instance.collection(_collection).where('for_d', isEqualTo: true).get();
return _snapshot;
}else if((forMap == false && element.data()['role'] == 'p') || (forMap == true)){
Future<QuerySnapshot> _snapshot = FirebaseFirestore.instance.collection(_collection).get();
return _snapshot;
}
}
});
}