I have created function as below :
fun getPercentage(id:String): String {
var percentage=""
scope.launch {
percentage=repo.getPercentage(id)?.get(0)?.percent.toString()
Log.e("$$$ value >>","$$$ value >>"+percentage)
}
Log.e("$$$ value outside >>","$$$ value >>"+percentage)
return percenatge
}
Here, I can not return the updated value using the varibale : percentage.
Logs I am getting is as below :
$$$ value outside >>
$$$ value >> 50
means I can't return the latest value. something going wrong with the flow.
Someone suggested me to use async{} and await(). But I don't know How it will be helpful here?
Please guide. Thanks.