I am trying to set the value of a variable which i have declared globally but when i am setting the value it sets to default ...
Let me show you the code ...
var userWeight:Double = 0.0
Here i am trying to update the userWeight Value but it sets to 0.0 outside of the sucesslistener and inside it the value is correctly updated ...
Here is my log to clarify this better
getUserDetails().addOnSuccessListener { document->
userWeight = document.toObject(User::class.java)!!.weight.toDouble()
Log.d("temperory","$userWeight")
}
getUserDetails().addOnSuccessListener { document->
userWeight = document.toObject(User::class.java)!!.weight.toDouble()
Log.d("temperory","$userWeight")
}
Log.d("weightuser","$userWeight")