Trying to switch an app over to stateflow with databinding but get the error
Two-way binding cannot resolve a setter for kotlinx.coroutines.flow.MutableStateFlow
xml
<androidx.appcompat.widget.SwitchCompat
android:id="@+id/notificationsSwitch"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:checked="@={viewModel.enable}"
android:layout_gravity="center_vertical"
android:theme="@style/Switch" />
code
val enable = MutableStateFlow(true)
I have databinding enabled in gradle
buildFeatures {
dataBinding true
}
liveData works fine but would like to remove it for flows
You may need to upgrade your gradle version to 7.0+, as mentioned here: https://youtu.be/JnN6EFZ6DO8?t=933