I’m trying to check if my collection has a document by a function
this is the function:
@override
Future<bool> exist(String uid) async {
final snapShot = await collectionRef.doc(uid).get();
if (snapShot.exists){
return true;
}
return false;
}
the result is : Instance of ‘Future’ ,, (neither True nor false)
pointing that my function into Provider
2
Answers
The method is fine, you probably aren’t awaiting it when calling it elsewhere.
Also, a slight improvement would be to just
return snapShot.exists
instead of theif(exists) return true, else false
.Since it’s a future when you call this method like
Will throw an error saying its an instance of future.
But if you await to get a return you should get a bool
To check it in a condition