Hi, i got really weird error inside android studio...
# android
s
Hi, i got really weird error inside android studio 4.0.1 with kotlin 1.4.10. I am not sure if it bug from android lint and where i should report it. In the example below code works normally but android linter return error with message
Error: 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.
Copy code
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 {
            ""
        }
    }
}
i