shusek
09/14/2020, 4:25 PMError: Expected non-nullable value [NullSafeMutableLiveData] androidSingleEvent.value = validationError
.
Probably some lint check from library androidx.lifecycle:lifecycle-*:2.3.0-alpha07
is invalid.
Funfact: when i change validationError
to (validationError)
linter passes without problem.
class TestClass {
val androidSingleEvent = MutableLiveData<String>()
fun test() {
val nullableText = getNullableText(true)
if (nullableText != null) {
androidSingleEvent.value = nullableText
}
}
private fun getNullableText(returnNull: Boolean): String? {
return if (returnNull) {
null
} else {
""
}
}
}
Ian Lake
09/14/2020, 5:25 PM