this is my function, my problem is: When I'm call this function, first return a null value, after that, the "println" line prints in console all the content of the document and it´s not null
fun readDescriptor(email: String): HashMap<String, Any>? {
var result: HashMap<String, Any>? = null
db.collection("users").document(email).collection("descriptor").document("personal").get()
.addOnSuccessListener { document ->
if (document.data != null) {
result = document.data as HashMap<String, Any>
println("Content of document: $document.data")
} else {
result = null
}
}
return result
}
how can I get objectively if a document exist or not? ty