Hi guys, I’m trying to validate a TextField with Jetpack Compose using StateFlow on a ViewModel I saw an example that looks like this:
val isButtonEnabled: StateFlow<Boolean> =
combine(isLoading, login, password) { isLoading, login, password ->
isLoading.not() && login.isNotBlank() && password.isNotBlank()
}.stateIn(viewModelScope, SharingStarted.Eagerly, false)
But I only have 1 field instead to validate so I try to put it like this
val isContinueEnable: StateFlow<Boolean> = MutableStateFlow(login.value.isNotBlank())
.stateIn(viewModelScope, SharingStarted.Eagerly, false)
but when I start typing on the TextField it doesn’t change de value to
true
so is there a method similar to
combine
to get
Flow
but just with one element?