Having a flow called `userPreferencesRepository.se...
# compose
p
Having a flow called
userPreferencesRepository.searchText
, why this can be done:
Copy code
userPreferencesRepository.searchText.collect{ searchText = it }
but this not?
Copy code
searchText = userPreferencesRepository.searchText.collect{it}
returning simply it from collect should work, but instead it gives me this error:
Type mismatch. Required:String Found:Unit
s
If you want to assign to a state object directly, instead of collect use collectAsState() inside your composable https://developer.android.com/develop/ui/compose/state#use-other-types-of-state-in-jetpack-compose
p
thank you
👍 1