A. Albrg
A. Albrg

Reputation: 733

Cannot find a setter for that accepts parameter type 'kotlinx.coroutines.flow.MutableStateFlow' DataBinding Android

I'm using data-binding to handle MutableStateFlow in my ViewModel

  private val _searchSkeleton = MutableStateFlow(View.GONE)
  val searchSkeletonVis = _searchSkeleton

Here's my usage in the XML file

  app:viewVisibility="@{viewModel.searchSkeletonVis}"

And this is my BindingAdapter

@BindingAdapter("app:viewVisibility")
fun bindViewVisibility(
    @NonNull view: View,
    @NonNull visibility: Int,
) {
    view.visibility = visibility
}

and it gives me this error

Cannot find a setter for that accepts parameter type 'kotlinx.coroutines.flow.MutableStateFlow'

But when I use LiveData it's working fine!

Upvotes: 1

Views: 2249

Answers (1)

A. Albrg
A. Albrg

Reputation: 733

Stateflow is only supported in Android Gradle Plugin version 7.0.0-alpha04 or higher as per the documentation.

Upvotes: 5

Related Questions