找不到接受参数类型 'kotlinx.coroutines.flow.MutableStateFlow' DataBinding Android 的 setter

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

我在我的 ViewModel 中使用数据绑定来处理 MutableStateFlow

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

这是我在 XML 文件中的用法

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

这是我的 BindingAdapter

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

它给了我这个错误

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

但是当我使用 LiveData 时它工作正常!

Stateflow 仅在 Android Gradle 插件版本 7.0.0-alpha04 或更高版本中受支持 documentation