// viewmodel中定義兩個數據
class LoginViewModel @Inject constructor() : BaseViewModel<LoginIntent>() {
val height = MutableStateFlow(-1f)
val weight = MutableStateFlow(-1f)
}
// UI中使用該數據做判定:
BaseLoginScreen(
canNextClick = vm.weight.collectAsState().value!=-1f && vm.weight.collectAsState().value!=-1f,
) { 。。。 }
// 此時會報錯,提示Backend Internal error: Exception during IR lowering,還有Runtime JAR files in the classpath should have the same version.
// 然而改成下面這種形式就對了:
val height = vm.weight.collectAsState().value
val weight = vm.weight.collectAsState().value
BaseLoginScreen(
canNextClick = height!=-1f && weight!=-1f,
) { 。。。 }